2Angel
asked on
VB6: gtting the line number on error log
I have an application written in VB6. On Error occure - the program writing to ErrorLog (txt file).
How can I get on me ErrorLog on which Sub and line the error occured?
Tks
How can I get on me ErrorLog on which Sub and line the error occured?
Tks
ASKER
this exactly what I do - but I need to get the line number - is it possible?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One tricky part about Erl() is that the error occured at or after the line number returned by Erl(). If you don't number every executable line the returned value can be deceiving.
For example:
10 x = 310
20 y = 213
z = 1 / 0
30 result = x + y + z
The division by zero error occurs at the unnumbered line between 20 and 30, so Erl() returns 20.
At one time it was a documented function, but I don't recall when or why Microsoft removed it from the docs.
For example:
10 x = 310
20 y = 213
z = 1 / 0
30 result = x + y + z
The division by zero error occurs at the unnumbered line between 20 and 30, so Erl() returns 20.
At one time it was a documented function, but I don't recall when or why Microsoft removed it from the docs.
ASKER
Thank you for your comments.
Why on VBS I get the line number and even the chr' cause the error with out numbering the lines?
Tks!
Why on VBS I get the line number and even the chr' cause the error with out numbering the lines?
Tks!
ASKER
Also, something to think about: when error ocure the program jump to the Error Handler and the, if there is a command Resum Next, the program jump back to the next line that cause the error - how does it know where to jump back? Can I retrieve that data (the line bumber to jump back)?
>Can I retrieve that data (the line bumber to jump back)?
No.
No.
ASKER
but the compiler "know" to which line to jemp back - where "he" stor that information?
>where "he" stor that information?
Someplace inaccessible to the VB programmer. Just another example of the VB architects keeping low level details away from the programmer.
Someplace inaccessible to the VB programmer. Just another example of the VB architects keeping low level details away from the programmer.
ASKER
Thanks!
Is there another "VB" (VB.NET?) that "give" that information "builtin"?
Is there another "VB" (VB.NET?) that "give" that information "builtin"?
I don't know, I'm still a beginner at VB.Net.
ASKER
OK - do you know source code (I need a code) to "make" those numbering?
>OK - do you know source code (I need a code) to "make" those numbering?
MZTools, as Taconvino already suggested.
I usually want to add line numbers to some subs or just some parts of a sub. I copy the code selection into Textpad where I run a macro that adds line numbers, then I paste the code back into VB. I've read that Notepad++ does line numbering, so one doesn't have to write a macro. It's a free replacement for Notepad. see http://notepad-plus.sourceforge.net/uk/site.htm
MZTools, as Taconvino already suggested.
I usually want to add line numbers to some subs or just some parts of a sub. I copy the code selection into Textpad where I run a macro that adds line numbers, then I paste the code back into VB. I've read that Notepad++ does line numbering, so one doesn't have to write a macro. It's a free replacement for Notepad. see http://notepad-plus.sourceforge.net/uk/site.htm
error_handler:
call fn_log_errors(err.number, err.description, "modMain.sbDoThis")
You could save some time and use a module-level string for the form-module-class name...