crowleyd
asked on
Why an Overflow Message ?
Can anyone help with the below. I've never sees this before !
Add the following lines of code to a new project and run :-
Dim lngTest As Long
lngTest = 12 * 3600
This produces as "Overflow" which I can only get around with :-
Dim lngTest As Long
lngTest = 3600
lngTest = 12 * lngTest
Wierd or am I being Thick ?
Many Thanks
Dave
Add the following lines of code to a new project and run :-
Dim lngTest As Long
lngTest = 12 * 3600
This produces as "Overflow" which I can only get around with :-
Dim lngTest As Long
lngTest = 3600
lngTest = 12 * lngTest
Wierd or am I being Thick ?
Many Thanks
Dave
Hi Dave
Strange behaviour. It seems that it should work.
It doesn't seem that the variable lngTest is the problem since I get the same overflow error in the Debug window by typing "? 12 * 3600" so I went to msdn help and they say to write the code in the manner below. Lo and behold it works!!!
Dim lngTest As Long
lngTest = 12 * CLng(3600)
Happy New Year
Sicilian
Strange behaviour. It seems that it should work.
It doesn't seem that the variable lngTest is the problem since I get the same overflow error in the Debug window by typing "? 12 * 3600" so I went to msdn help and they say to write the code in the manner below. Lo and behold it works!!!
Dim lngTest As Long
lngTest = 12 * CLng(3600)
Happy New Year
Sicilian
I have tested this thoroughly and have deermined that VB is interpreting the literal 36000 as an INTEGER rather than long. It seems that VB sees 12 (well with the range of integer) and then 36000 (Long integer) and can't decide which way to go with it. Weird.
Good luck!!
Good luck!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>12# * 3600
or
12& * 3600&
or
12& * 3600&
Interested to know the answer also.