I have a program to calculate wattage from voltage and amps. If I declare V and I on different lines, then I get an overflow when V = 1000 and A = 100. If I declare them on the same line, then the overflow is fixed and doesn't occour
Code:
Private Sub cmdCalc_Click()
Dim W As Long
Dim Amps As Integer
Dim Voltage As Integer
Voltage = CInt(txtVolts.Text)
Amps = CInt(txtAmps.Text)
If Voltage >= 1 And Voltage <= 1000 Then
If Amps >= 1 And Amps <= 100 Then
W = CLng(Voltage * Amps)
txtWatts.Text = W
Else
MsgBox "Enter amps between 1 and 100"
End If
Else
MsgBox "Enter volts between 1 and 1000"
End If
End Sub
Comment