• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3816
  • Last Modified:

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
0
2Angel
Asked:
2Angel
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
The only way you can do that would be to pass the sub name in your error handler, which means you'll have to manually type it into every error log call.  Like...

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...
0
 
2AngelAuthor Commented:
this  exactly what I do - but I need to get the line number - is it possible?
0
 
TaconvinoCommented:
You could use Erl (undocumented) function.  Here's a nice article about pros and cons using this:

http://www.informit.com/articles/article.asp?p=25180&rl=1

MZTools can make a nice job numbering lines for you.

+TCV
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
samstarkeyCommented:
I agree with Taconvino,

MZTools is the way to go

http://www.mztools.com/v3/mztools3.htm

0
 
dancebertCommented:
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.
0
 
2AngelAuthor Commented:
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!
0
 
2AngelAuthor Commented:
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)?
0
 
dancebertCommented:
>Can I retrieve that data (the line bumber to jump back)?

No.
0
 
2AngelAuthor Commented:
but the compiler "know" to which line to jemp back - where "he" stor that information?
0
 
dancebertCommented:
>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.
0
 
2AngelAuthor Commented:
Thanks!
Is there another "VB" (VB.NET?) that "give" that information "builtin"?
0
 
dancebertCommented:
I don't know, I'm still a beginner at VB.Net.
0
 
2AngelAuthor Commented:
OK - do you know source code (I need a code) to "make" those numbering?
0
 
dancebertCommented:
>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
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now