Is there any way to get the current sub/function name from VB? For error logging purposes, I would like to call a WriteError function and pass the current sub/function that has caused the error?
Thanks!
Kevin
Printable View
Is there any way to get the current sub/function name from VB? For error logging purposes, I would like to call a WriteError function and pass the current sub/function that has caused the error?
Thanks!
Kevin
That'll help ya!Code:Private Sub JustASub()
On Error Goto ErrorHandler
'DO all the things you want in this sub
Exit Sub 'when no errors occur
'Copy the error handler in every function/sub
ErrorHandler:
Call WriteError(JustASub, Err.Number)
End Sub
Private Sub WriteError(ErrSub As String, ErrNr As Long)
fn = FreeFile
Open "err.log" For output as #fn
Print #fn, "Error " & ErrNr & " occured in sub: " & ErrSub
Close #fn
End Sub
[Edited by Jop on 10-13-2000 at 12:01 PM]
Unfortunately there's no way to do that in VB.
No, there's not an 'official' way...
but also try App.LogEvent and App.StartLogging, maybe those'll help ya!