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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overflow error?? 3

Status
Not open for further replies.

Kryzsoccer

Programmer
Oct 15, 2002
85
US
Why will this return an overflow error:

Dim hello As Long
Private Sub Form_Load()
hello = 15 * 3 * 18 * 45
End Sub

but this will work fine:

Dim hello As Long
Private Sub Form_Load()
hello = 15 * 3
hello = hello * 18 * 45
End Sub

Are they not both doing the exact same thing??

As always, ALL help is appreciated!!
 
thats a very interesting point... which i never knew about.... a splat for you!!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
The Great Date Debate Thread222-368305
File Formats Galore @ or
 
Casting the first element to Long will prevent the problems.
___
Dim hello As Long
hello = 15& * 3 * 18 * 45
Msgbox hello
 
Thanks for all the help!!
In my program the numbers were actualy variables. I converted them all to longs and the problem was solved. Thanks for all your help!! Stars for both of you.
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top