ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   knowing error line and module name (https://www.excelbanter.com/excel-programming/349010-knowing-error-line-module-name.html)

x taol

knowing error line and module name
 


i wanna know error line and module name when outbreak of error in any
module.

Sub test()
On Error GoTo erohandle:
~~~~~
~~~~~
Exit Sub
erohandle:
MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
is " & yyyyy
End Sub


*** Sent via Developersdex http://www.developersdex.com ***

Tom Ogilvy

knowing error line and module name
 
look at help on erl - however you have to have explicit line numbers written
into your code (the old Basic way).

Other than that, you will have to code it yourself.

--
Regards,
Tom Ogilvy

"x taol" wrote in message
...


i wanna know error line and module name when outbreak of error in any
module.

Sub test()
On Error GoTo erohandle:
~~~~~
~~~~~
Exit Sub
erohandle:
MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
is " & yyyyy
End Sub


*** Sent via Developersdex http://www.developersdex.com ***




Bob Phillips[_6_]

knowing error line and module name
 
There is no automated way, but you could the module name in a constant and
scatter line numbers periodically through the procedure, and then use the
Erl function to get the last line
number encountered before the error was raised. E..g,

Here is an example

Sub TestErrorLineNumber()
Const sModule As String = "Module1"

On Error GoTo ErrHandler:
10:
' some code
20:
' more code
Err.Raise 1
'etc.
Exit Sub
ErrHandler:
MsgBox "Error: " & Err.Number & " " & Err.Description & vbNewLine & _
"in module: " & sModule & " in project: " & Err.Source & vbNewLine &
_
"around the following line: " & Erl
End Sub

You could also add the procedure name.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"x taol" wrote in message
...


i wanna know error line and module name when outbreak of error in any
module.

Sub test()
On Error GoTo erohandle:
~~~~~
~~~~~
Exit Sub
erohandle:
MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
is " & yyyyy
End Sub


*** Sent via Developersdex http://www.developersdex.com ***




Robin Hammond[_2_]

knowing error line and module name
 
The MZTools add in is quite useful for this.

There is a routine that add's/removes line numbers to your code, and a
routine that will add an error handler to a module with the name of the
module included automatically.

Robin Hammond
www.enhanceddatasystems.com

"x taol" wrote in message
...


i wanna know error line and module name when outbreak of error in any
module.

Sub test()
On Error GoTo erohandle:
~~~~~
~~~~~
Exit Sub
erohandle:
MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
is " & yyyyy
End Sub


*** Sent via Developersdex http://www.developersdex.com ***





All times are GMT +1. The time now is 08:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com