How can I retreive the line, module and prodedure where an error occurs?
Please give a detailed example
I want to have a fuction that will return:
The Module or Form that the error occurs in.
The Procedure that the error occurs in.
The line the error occurs in.
And of course in will return Err.Number and Err.Description.
From an exe you have to put context information in your code.
This can be
(a) a global which sets a context string
(b) a stack class which adds a context every time you do a call, and removes the context every time you return
option (b) can be a performance hit. option (a) doesn't always give you the info you need. so its down to what your requirements are.
From VB you can set tools - options - break on all errors. Then the debugger will break on the error line. I guess you knew that already ?
The undocumented Erl() function will return the line number where the error occured. For this to work you have to use line numbers. If the line with the error does not have a line number, Erl() returns the last numbered line before the error. This function was documented in earlier versions of VB.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
From an exe you have to put context information in your code.
This can be
(a) a global which sets a context string
(b) a stack class which adds a context every time you do a call, and removes the context every time you return
option (b) can be a performance hit. option (a) doesn't always give you the info you need. so its down to what your requirements are.
From VB you can set tools - options - break on all errors. Then the debugger will break on the error line. I guess you knew that already ?