Partager via


Finally (Visual Basic) 

Introduces a statement block to be run before exiting a Try structure.

Remarks

Each Try structure must include either a Finally block or at least one Catch block.

Note

Control does not pass from a Try or Catch block to the corresponding Finally block in the following cases:

When to Use Finally

If you have one or more statements that must run before you exit the Try structure, use a Finally block. Control passes to the Finally block just before it passes out of the Try structure. This is true even if an exception occurs anywhere inside the Try structure.

The Finally keyword can be used in this context:

Try...Catch...Finally Statement (Visual Basic)

See Also

Reference

Catch (Visual Basic)
Visual Basic Language Keywords