VB Error Handling

155 pts.
Tags:
Error handling
Error Messages
Error Report
Software development
VB
VB error handling
Visual Basic
Visual Basic 6
Visual Basic developers
While execution of my program's exe, the EndUser sometimes get run time error or application defined error etc., which are not handled by me in my code. So, in each & every 'Sub' or 'Function', before 'End Sub' or 'End Function', I have put these lines... If Not Err.Number = 0 Then MsgBox Me.Name & " - < sub or function name >" & VBA.Chr(13) & Err.Number & " - " & Err.Description End If for e. g., Private Sub Form_Load() On Error GoTo Er . . . Er : If Not Err.Number = 0 Then MsgBox Me.Name & " - Form_Load" & Chr(13) & VBA.Err.Number & " - " & Err.Description End If End Sub Now, my question is how to know that exactly what is the line number in the code, where this error is raised. So, I can show that line number or line code in error message, which finally end-user can inform me.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I’ve been through this with a PC out on the shop floor running a VB program and getting errors that I couldn’t duplicate at my desk. Start with adding the current sub/function name to the error message. When you have which one is actually getting the error, add a variable to that sub/function and create your own line numbers, incrementing the number for each line in the sub/function and send that number to the error message box.

Hope this helps.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Mayuri
    Thank You for attending my question. Yesterday I got another solution similar to yours, from "http://www.aivosto.com/vbtips/errorhandling.html" Accordingly, there is a variable 'Erl" , that gives line number of code when error raise.
    155 pointsBadges:
    report
  • carlosdl
    I think you need to use a third party tool in order to use that variable for line numbers.
    70,200 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following