Originally posted by peet
this is strange ....

I tried this
MsgBox 1000 * 60 * 60

i returns overflow as well.. so I guess u cannot use the * operator on anything that will return a number larger than integer. ????

try replacing it with 3600000

I don't have a good expl. though... sorry
Peet

Kaverin was along the right track. Vb appears look at numbers involved in mathematical operations and it makes assumptions about the data types if not explicitly declared beforehand. However it does not always treat undeclared datatype numbers as integers.

E.g. 1

Debug.Print 32767 * 1 will work
Debug.Print 32767 + 1 will fail as limit of integer is reached
here Vb has assumed 32767 and 1 are both integers and tries to hold the result in an integer the limit of which is 32767; so 32767 + 1 creates an overflow error.


E.g. 2

Debug.Print 2147483647 * 1 will work.
Debug.Print 2147483647 + 1 fails as VB tries to hold the result as a long and 2147483647 + 1 breaches the limit of a long


E.g. 3
Debug.Print 1000 * 60 * 60& will fail as VB tries to hold the value of 1000 * 60 in an integer which causes an overflow.

To prevent errors you can declare the datatypes before hand or during the operation with the shorthand declarations such as #,&,%,@.