I know this is old but I recently discovered you can make individual stackframes from an Exceptions stacktrace object. Which means it handles the parsing for you.
I remembered this topic while answering another one.VB Code:
Try Dim x As Integer = 1 Dim y As Integer = 0 Dim z As Integer = x / y Catch ex As Exception 'create a stacktrace object from the except to parse it Dim st As New StackTrace(ex, True) 'this just shows the first stackframe but there could be many Dim sf As StackFrame = st.GetFrame(0) MsgBox(String.Format("{0} {1} {2}", ex.Message, IO.Path.GetFileName(sf.GetFileName), sf.GetFileLineNumber), MsgBoxStyle.Critical) End Try




Reply With Quote