carfreak01
Industrial
- Nov 26, 2002
- 36
Does anybody know why if I write this code in a command button:
Private Sub CommandButton1_Click()
Dim x As Long
x = 2000 * 365
Worksheets("Sheet1").Range("A1").Value = x
End Sub
The program detects an Overflow error,
But if I type the following code:
Private Sub CommandButton1_Click()
Dim x As Long, b As Long, c As Long
b = 2000
c = 365
x = b * c
Worksheets("Sheet1").Range("A1").Value = x
End Sub
It runs perfectly?
Private Sub CommandButton1_Click()
Dim x As Long
x = 2000 * 365
Worksheets("Sheet1").Range("A1").Value = x
End Sub
The program detects an Overflow error,
But if I type the following code:
Private Sub CommandButton1_Click()
Dim x As Long, b As Long, c As Long
b = 2000
c = 365
x = b * c
Worksheets("Sheet1").Range("A1").Value = x
End Sub
It runs perfectly?