VB Error Handling
155 pts.
0
Q:
VB Error Handling
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.
ASKED: Jan 22 2009  7:03 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
685 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
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.
Last Answered: Jan 22 2009  11:25 PM GMT by Vatchy   685 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Mayuri   155 pts.  |   Jan 23 2009  10:15AM GMT

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.

 

Carlosdl   29855 pts.  |   Jan 23 2009  2:06PM GMT

I think you need to use a third party tool in order to use that variable for line numbers.

 
0