Solved

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

Posted on 2008-06-12
2
149 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
[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
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

710 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