Re: variable overflow in VBA
What happens on a overflow depends on your error handling
3 Examples, Normal, with error handling and the worst ignoring any errors
Code:
Sub test1()
Dim I As Integer
For I = 32760 To 32768
Next
End Sub
Sub test2()
Dim I As Integer
On Error GoTo test2_Error
For I = 32760 To 32768
Next
On Error GoTo 0
Exit Sub
test2_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure test2 of Module Module1"
End Sub
Sub test3()
Dim I As Integer
On Error Resume Next 'this will ignore the error and continue
For I = 32760 To 32768
Next
End Sub
Now with a nice errorhandler
Re: variable overflow in VBA
thanks for the reply
i guess without the error handler, the behaviour is indeterminate, correct?
Re: variable overflow in VBA
If the variable overflows you will generate an error. Just trap for that error. Best thing to do i=s to dimension your variables with the proper type and size.
Re: variable overflow in VBA
thanks for the reply robdog
what kind of error will the variable overflow generate?
how does one trap for that error?
what is i=s?
Re: variable overflow in VBA
Well, create the overflow and see what the error number is. Then trap for that in your error handler (If err.Number = 5614 then... and no, I don't know what the correct error number is, 5614 is an example).
i=s is probably a typo for is, as in "Best thing to do is..." ;)
Re: variable overflow in VBA
thanks for the reply
there were overflows within my program, but the program just seemed to go in a loop and did not give any errors