|
-
May 3rd, 2004, 11:51 AM
#1
Debugging tip
This may be old news to many but I had to debug a project that needed to run on a machine with a scanner and did not have Visual Basic on it for me to debug. I added this to the error handler and it helps by giving the line number of the error.
Use the Erl Function to Debug
When you’re faced with difficult debugging chores or when you want to enhance the value of error logs produced by production code, line numbers can help determine exactly where errors are occurring. The Erl function, not documented since VB3, pinpoints the problem. Here’s an example of how Erl returns the line number of an error:
Public Sub DivideByZero()
On Error GoTo HandleError
10 Dim x As Long
20 Dim y As Long
30 y = 5
40 MsgBox y / x 'error
Exit Sub
HandleError:
Debug.Print "Error on line " & Erl
End Sub
There is a free tool called MZTools that has a lot of nice features and one is to automatically assign line numbers to a project. Using that and Erl helps debugging exes.
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
|