PDA

Click to See Complete Forum and Search --> : Overflow (Error 6)


funkyd77
Jan 10th, 2000, 06:00 PM
I had this problem today and had to use the prescribed work-around. This is from the msdn library:

You attempt to use a number in a calculation, and that number is coerced into an integer, but the result is larger than an integer. For example:
Dim x As Long
x = 2000 * 365 ' Error: Overflow
To work around this situation, type the number, like this:

Dim x As Long
x = CLng(2000) * 365

-------------

This seems a bit stupid. Can't visual basic tell that it's a Long integer. Why does this "coercing" happen. Sounds more like a glitch in the compiler to me. Does anyone know of a better work-around than the one microsoft prescribes?

Thanks in advance,

Mark Sreeves
Jan 10th, 2000, 06:11 PM
Yeah I've come across this before as well!

one way round it is sticking .0 on the end so it becomes single
VB is so crap er.. I mean weakly typed that it lets you do this.

Dim x As Long
x = 2000.0 * 365.0

------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company