VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Mysterious Overflow Problem

by deepblue99999999 (3 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (7 Votes)

One day, I was performing calculation on numeric variables.I kept getting error message "Overflow" so I checked my variable declaration, it's declared as Long, but the operation of the two numeric values gave 2500. I was confused at first, finally I brought up MSDN help and discovered the solution.

Rate Mysterious Overflow Problem

This will generate an error message "Overflow"
Sub Command1_Click()
Dim X As Long
X = 2000 * 350
End Sub
'This is the solution I got from MSDN.
Sub Command1_Click()
Dim X As Long
X = CLng(2000) * 350 Or
X = 2000 * CLng(350)
End Sub

Download this snippet    Add to My Saved Code

Mysterious Overflow Problem Comments

No comments have been posted about Mysterious Overflow Problem. Why not be the first to post a comment about Mysterious Overflow Problem.

Post your comment

Subject:
Message:
0/1000 characters