Solved

Tracking any line of code that throws an error.

Posted on 2004-08-05
6
192 Views
Last Modified: 2012-05-05
Is there a way in VB6 to know exactly what line of code errored when the error handling is called?

Does VB track the line it is executing in a variable or something while it is processing. Something like a variable called strCodeExecuting that whenever on error is encountered I can write the variable out and know exactrly the line of code that was trying to be executed?

I want to keep a log of all errors, clients do not always tell me what the actual error was, or all the errors for that matter.

Thanks,
Mike
0
Comment
Question by:MGC22
  • 3
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
bkthompson2112 earned 50 total points
ID: 11729280
Hi MGC22,

You can use the undocumented erl() function to display the line number in your error log.

See here: http://www.awprofessional.com/articles/article.asp?p=25180

bkt
0
 
LVL 18

Assisted Solution

by:JR2003
JR2003 earned 50 total points
ID: 11730170
NB: To use the erl function you have to number all you lines of code
0
 

Author Comment

by:MGC22
ID: 11730215
I was hoping for the actual text of the line but the line number could work.
As JR2003 mentions about the line numbers, is there a way to automate putting in the line numbers in VB6?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Expert Comment

by:JR2003
ID: 11742139
The source code for a vb add-in to add line numbers to code is here:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=49876&lngWId=1
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11742143
In fact here's a better one and it's freeware!

www.mztools.com 
0
 
LVL 6

Expert Comment

by:bkthompson2112
ID: 11906803
Thanks :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Macro: Delete a Row if Column A and B match (in that Row) 2 72
Window placement 17 74
How to create a duplicate finder Application 9 113
Visual Studio 2005 text editor 10 35
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now