Is there a way to report the line number that an error occures when you are running a program. VB6 used ERL().
Anyone know what to use VB.Net.
Printable View
Is there a way to report the line number that an error occures when you are running a program. VB6 used ERL().
Anyone know what to use VB.Net.
MsgBox(Err.Description)
Will give you the description of the error and the line number
Not sure about just the line number
VB Code:
Try Dim x As Integer = 1 Dim y As Integer = 0 Dim z As Integer = x / y Catch ex As Exception MsgBox(String.Format("Here is the whole stacktrace:{0}{1}", ControlChars.NewLine, ex.StackTrace), MsgBoxStyle.Critical) 'create a stacktrace object from the except to parse it Dim st As New StackTrace(ex, True) MsgBox(String.Format("Here is the just the line number:{0}{1}", ControlChars.NewLine, st.GetFrame(0).GetFileLineNumber), MsgBoxStyle.Critical) End Try
I did a little searching and MS says that ERL is still supported in .net?
See here:http://support.microsoft.com/default...b;en-us;311326
So they say this should work
MsgBox(Err.Erl)
Hope that Helps!:wave:
thanks for all the replies