|
-
Feb 21st, 2000, 04:00 PM
#1
Thread Starter
Member
...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
-
Feb 21st, 2000, 04:13 PM
#2
Frenzied Member
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
-
Feb 21st, 2000, 05:26 PM
#3
Fanatic Member
That's right, use Public. Global I beleive is for Global objects in classes (class modules)
-
Feb 22nd, 2000, 01:32 AM
#4
New Member
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
-
Feb 22nd, 2000, 01:41 AM
#5
Thread Starter
Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|