Solved

Is there a way of knowing on wich line an error occured?

Posted on 2008-06-12
2
138 Views
Last Modified: 2010-04-30
When prog. has already jumped to ErrorHandler?
(Can't disable error handling in this case)
0
Comment
Question by:davidsperling
2 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 21767176
Nope. It's one of those annoying things about VB/VBA error handling.

What you can do is add line numbers. VB and VBA error handling includes the ability to display the line number of the statement in error with the following caveats: the line number is only accessible from within the routine where the error occurred, and line numbers reduce the ability to maintain code. That said, the line number is access using the Erl variable:

10   On Error GoTo MyRoutine_Error
20   ...
80   Exit Sub
MyRoutine_Error:
90   MsgBox "Error """ & Err.Description & """ occurred at line " & Erl & " of MyRoutine"

A third party tool that can add and remove line numbers in a VB or VBA project can be found http://www.mztools.com/v3/download.aspx.

Kevin
0
 
LVL 4

Author Comment

by:davidsperling
ID: 21767197
Well, if you can't disable error handling you can't add line numbers to the code either ;-) (It's n add-in I cannot change)

Thanks anyway, the points are your's :-)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
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 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…
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now