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

Curious Overflow Error 2

Status
Not open for further replies.

IanAble

Programmer
Jan 24, 2005
112
GB
Hi all. I'm getting a really strange Overflow error when multiplying numbers. Here's what I've found:

Msgbox 60 * 1 - no error
Msgbox 60 * 10 - no error
Msgbox 60 * 100 - no error
Msgbox 60 * 1000 - overflow error.

What am I missing?
 
Msgbox clng(60) * 1000 ' - no overflow error.

VBA I think, will try to use the smallest datatype possible, based on the numbers provided. Here that would be integer, where the result of the operation would overflow. Explicitly casting at least one of them to a larger datatype, should normally work.

Roy-Vidar
 
Thanks Roy it worked like a charm. I'll have to watch out for that in the future!
 
Another way:
Msgbox 60 * 1000#

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top