-
...to me at least. The experienced among you will probably know what's up immediately.
Anyways, here's the situation:
module-1
global buffer as long
public const MAX_XRES= 800
public const MAX_YRES= 600
form-1
buffer= MAX_XRES * MAX_YRES
THIS CAUSES AN OVERFLOW ERROR (6)
800*600 (480000) > 2^32 ???!!
If I simply say:
buffer= 480000, there's no problem
Obviously, VB is playing some odd type conversion game; if anyone can tell me exactly what's going on here, I'd really appreciate it.
Thanks
-
I expect someone else will explain why it does it but this works
Code:
Public buffer As Long
Public Const MAX_XRES As Long = 800
Public Const MAX_YRES As Long = 600
------------------
Mark Sreeves
Analyst Programmer
[email protected]
A BMW Group Company
-
That's right, use Public. Global I beleive is for Global objects in classes (class modules)
-
Hi!
By default MAX_XRES and MAX_YRES are Integer.
As result when VB uses temp variable you have
Overflow! Just try:
public const MAX_XRES= 800.0
public const MAX_YRES= 600.0
In this case VB will use by default Single
HTH
-
Thanks everyone. I figured it was something like that. VB "ought" to be smart enough to know that an integer multiplied by an integer will have to be held in a long. Can't everything, I guess.