user1812899
user1812899

Reputation: 31

VBA Overflow error disappears in break mode

I have some code along the lines of the following:

redim a(1 to N)
for i = 1 to N
    a(i) = someFunction(i)
Next i

When running it, I get "Run-time error 6: Overflow". And it enters break mode with the line inside the loop: a(i) = someFunction(i) highlighted. To find the error, I step into that function and step over line-by-line. There's no error, it works fine and keeps going. As long as I execute the code this way, staying in break mode & stepping in to someFunction one call at a time, it works, but as soon as I go back to normal execution, the overflow error comes back.

Does anyone know how can I get rid of the overflow?

Upvotes: 3

Views: 320

Answers (2)

user1812899
user1812899

Reputation: 31

Thanks everyone for helping, I figured out what the problem was. It was something in someFunction causing the overflow, I'm not sure why it didn't happen in break mode, but I fixed what was causing it and it's working now.

Upvotes: 0

salih0vicX
salih0vicX

Reputation: 1373

You should provide whole function so we could see the way you declared variables.

The error is cause by wrong variable declaration. One or more of your variables has no capacity to accept the value (example: you declared variable i as Integer so it cannot accept the value like: i=55000; the maximum value for integer is somewhere around 32000 to 32800)...

Upvotes: 1

Related Questions