How to: Display an Exception's Message in Visual Basic
The exception object includes a number of properties that help identify the code location, the type, the Helpfile URL, and the reason for the exception. One of these, the Message property, describes the current exception.
To display the string associated with an exception
Use the Message property to display information about the current exception. This example catches a WebException and displays the associated message.
Try Throw New System.Net.WebException Catch ex As System.Net.WebException MsgBox("An exception occurred:" & vbCrLf & ex.Message) End Try
See Also
Tasks
How to: Catch an Exception in Visual Basic
How to: Throw an Exception in Visual Basic
How to: Test Code with a Try…Catch Block in Visual Basic
How to: Check an Exception's Inner Exception
Troubleshooting Exception Handling
Reference
Try...Catch...Finally Statement (Visual Basic)