|
-
Jul 6th, 2006, 05:10 AM
#1
Thread Starter
Frenzied Member
variable overflow in VBA
Hello
I was wondering what happened to the execution of a program after a variable overflows. does the program continue right after the code which does the overflow or is the execution indeterminate.
i have got this piece of code which seems to run of to the begining of the loop (where the offending piece of code was within the loop)
also in vba is there any way to ifnd out if a variable has overflown by using a breakpoint.
-
Jul 6th, 2006, 05:32 AM
#2
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
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Jul 6th, 2006, 02:37 PM
#3
Thread Starter
Frenzied Member
Re: variable overflow in VBA
thanks for the reply
i guess without the error handler, the behaviour is indeterminate, correct?
-
Jul 6th, 2006, 03:05 PM
#4
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 16th, 2006, 01:45 PM
#5
Thread Starter
Frenzied Member
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?
-
Jul 16th, 2006, 02:34 PM
#6
Frenzied Member
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..."
Tengo mas preguntas que contestas
-
Jul 16th, 2006, 06:03 PM
#7
Thread Starter
Frenzied Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|