Obtaining Line Number on Error

EPD Hater

Registered User.
Local time
Today, 10:38
Joined
Mar 30, 2003
Messages
50
When an error is encountered during the execution of a module, on error I am handling it by displaying the Err.Number with the Err.Description and Err.Source on a message box. However, for me, the programmer, I would like to know which line the error was encountered on. Is there an object property that contains this information?

Thanks,
Nick
 
Just did a little experiment, using line numbers in the module (I don't know how to get them through the IDE, but MZTools, which is a freeware, can), then one can use the (as far as I know, undokumented) Erl statement to get the line number.
 
This is a good tutorial on debugging:
http://www.fmsinc.com/tpapers/vbacode/Debug.asp



Additionally you may want go here as well:
http://www.keysound.com/html/line_numbers.htm


Both cases say the same thing. They use Erl, but you have to number the lines yourself. That being said, you might be able to line them on load with Application.VBE.CodePanes("Form_Main").CodeModule.ReplaceLine ... I'm not sure if ReplaceLine is the one to use, or you may want to delete/insert lines, but you may be able to line your code automatically this way.

Give it a try and let me know
 

Users who are viewing this thread

Back
Top Bottom