By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

OverFlow - Runtime Error 6

P: 63
Expand|Select|Wrap|Line Numbers
  1.   Dim tempLeft As Long
  2.   Dim tempWidth as integer
  4.   tempLeft = Round(((tempWidth - i) * 100) / 18.39, 1)

When I try to run this code and when tempWidth = 343, I get Runtime error 6 - overflow.

I have no idea how to get rid of it ... can anyone please help me with this??
Jan 12 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 8,434
Use Long instead of Integer, perhaps.

Keep in mind, VB will do the calculation using the smallest data type it thinks it can get away with. So if you force all the values to be seen as Long (or Single, or anything big enough) it will work.

By the way, just out of curiosity, what data type is i? And while we're at it, the value?

Hm... what version of VB are you using? I just pasted your code into VB6, inserted tempWidth = 343 and it worked OK.
Jan 13 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.