How to get hold of the linenumber of the line where an error occurred
Hi. I have tried ( in vain ), when executing the VB executable,
to find out how to show the line number of the error that occurs.
I can access the line number when I'm in the VB IDE environment, but not when I run the executable.
Below is the code I use to access the line number
( I also triedlo_stacktrace.ToString(), but again the line number did not show when I ran the executable )
This leads me to the question: Is it at all possible to access the line number when the executable is run ?
PrivateFunction CodeRef(ByVal po_ModInfoAs t_ModInfo _
,ByVal po_exAs Exception _
,ByVal pb_ReturnSourceAsBoolean _
,ByVal pl_FrameNoAsLong _
)AsString
Dim lo_stackframeAs StackFrameDim ls_CodeRefAsStringlo_stackframe =
New StackTrace(po_ex,True).GetFrame(pl_FrameNo)If (pb_ReturnSource)Thenls_CodeRef = po_ex.Source
Elsels_CodeRef =
""EndIfls_CodeRef = ls_CodeRef _
&
"." & po_ModInfo.ModuleName _&
"." & lo_stackframe.GetMethod.Name _&
" ( " & lo_stackframe.GetFileLineNumber &" )"Return ls_CodeRefEnd
Function
