Solved

Tracking any line of code that throws an error.

Posted on 2004-08-05
6
191 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now