Solved

How can I retreive the line, module and prodedure where an error occurs?

Posted on 2004-04-25
4
129 Views
Last Modified: 2010-05-02
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.

0
Comment
Question by:brianshoenhair
4 Comments
 
LVL 8

Expert Comment

by:plq
ID: 10911248
Basically its not possible, but...

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 ?
0
 
LVL 18

Accepted Solution

by:
Sethi earned 60 total points
ID: 10911374
I use third party tool named CodeSmart 2003. The error handler's written with this tool can tell me the exact line and place of the error.
0
 
LVL 9

Assisted Solution

by:dancebert
dancebert earned 40 total points
ID: 10914216
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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

757 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

17 Experts available now in Live!

Get 1:1 Help Now