Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error handling - show line that caused error 2

Status
Not open for further replies.

justagrunt

Technical User
Oct 10, 2002
132
0
0
Hi,
Simple question.
Err_messageError:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description

Gives the message Error 438 etc.
How do I use Debug to also show the line that the code stopped at?
Ta
Bill
 
If you comment out the On Error line for the development, you should get the error line highlighted.
 
I put an exit sub in to exit under normal conditions. I can also use Ctrl Break while the message is showing. I right click on the resume line and select Set Next Statement, the code jumps to the resume line. I then hit F8 and the code jumps to the error line.

Err_messageError:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
exit sub
resume
 
I think with linenumbering, you can use the not so very documented Erl statement for debugging.

[tt]dim s as string
on error goto myerr
10 s = "test"
20 err.raise 6
30 msgbox s
myerr:
40 debug.print err.number & " - " & erl & " - " & err.description[/tt]

For easy linenumbering, check out
Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top