Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-25
4
Medium Priority
?
136 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 120 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 80 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
Suggested Courses

670 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