Lets you catch many errors that can occur in a given block of code.
Try [ try_statements ] [ Catch [ catch_parameter ] [ catch_statements ] ] … [ Finally [ finally_statements ] ] End [ Try ]
- Optional statements in which errors can occur.
- Optional, repeatable start of a block of statements that execute when an error occurs.
- Optional declaration of an object variable. The type of the object supplied to Throw selects the block (Catch) to execute.
- If not given, then Catch will execute for all exceptions. This can be done only as the last Catch.
- Optional statements that execute when an error occurs.
- Optional statements that always execute. If an error occurred, the statements execute after Catch is done.
- Completes the statement. You can also use End Try.
- You can change this part of the syntax. See @Option Directive for more information.
Try ' Cause a division by zero. x = a / 0 Catch #ex As Exception ' Do something about the error. End Try