Export (0) Print
Expand All

How to: Throw an Exception in Visual Basic 

This example throws an ApplicationException exception.

Example

Throw New ApplicationException
' Code to react to possible causes of the exception.

This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Visual Basic Language. For more information, see How to: Insert Snippets Into Your Code (Visual Basic).

Compiling the Code

This example requires:

  • A reference to the System namespace.

Robust Programming

Unhandled exceptions can cause application execution to halt. Use Try…Catch blocks to anticipate and handle possible exceptions.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft