Solved

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

Posted on 2004-04-25
4
131 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
passing a value with stream reader AFTER a ";" 3 67
Recommendation vb6 to vb.net or others 14 148
VB6 ListBox Question 4 44
Sub or Function is not defined 6 29
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

770 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