I'm using MsgBox(Exception.Message) to display the error, but when I use MsgBox(Exception.ToString) it displays more information about the error.
Is there a way to get only the form and the code line from the Exception.ToString?
Thanx.
Printable View
I'm using MsgBox(Exception.Message) to display the error, but when I use MsgBox(Exception.ToString) it displays more information about the error.
Is there a way to get only the form and the code line from the Exception.ToString?
Thanx.
I think the StackTrace is what you are looking for. Try:
MsgBox(Exception.StackTrace)
Sorry, it is not.
Exception.StackTrace is = Exception.ToString - Exception.Message
Id like to change this msgbox...
http://www.adecom.hpg.com.br/msgbox1.jpg
to...
http://www.adecom.hpg.com.br/msgbox2.jpg
:D
The stacktrace is the only thing with that info and sometimes it can be pretty long. I think if you want specific things out of it then you'll have to parse it and get what you need. There is no property or anything that returns just that part.
:(
What happened I thought you had posted a resolution?
I had, but it was not really working... :rolleyes:
Maybe this will help you out. I didn't study it, but it talks about the standard error messages and how to make a more robust system.
http://www.ftponline.com/vsm/2003_11...tures/dollard/
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