Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overflow problem

Status
Not open for further replies.

abaldwin

Programmer
Mar 27, 2001
798
US
Ran into this yesterday.

Here are two snippets of code that for all intents and purposes mathmatically are the same.

On a form place a command button and put the following code behind it.

Private Sub Command1_Click()
Dim dblResult
dblResult = 3418 * 68
MsgBox dblResult

End Sub

I get an overflow error on the multiplication. Have tried declaring the variable as double, integer etc.

Now try this

Private Sub Command1_Click()
Dim dblResult
dblResult = (34180 / 10) * 68
MsgBox dblResult

End Sub

Version is VB6 SP5

Thanks in advance
Andy

Andy Baldwin
 
Try this:

Dim dblResult
dblResult = CLng(3418) * 68
MsgBox dblResult

Swi
 
Check out this thread for a link I posted and some other explanations from other programmers:

thread222-608862

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top