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 start of a block of statements that you can use again and again. It executes when an error occurs.
- Optional declaration of an object variable.
The type of the object given to
Raiseselects which block (
- If not given, then
Catchwill execute for all errors. This can be done only as the last block of
- Optional statements that execute when an error occurs.
- Optional statements that always execute.
If an error occurred, then the statements execute after
- Completes the statement.
You can also use
- 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