Types of Exception Handlers

When you run a project as a compiled program or component, untrapped exceptions are fatal—they cause your program to terminate. You must make every effort to prevent this from happening. To prevent exceptions from stopping code execution (and terminating compiled programs), you create exception handlers to trap the exceptions. When an exception is trapped, Visual Basic doesn’t display an error message or terminate the application. Instead, code that you’ve written to specifically handle the exception is executed.

Note

In previous editions of Visual Basic, error handlers were created using On Error statements. This method of handling errors was considered an unstructured approach. Although Visual Basic .NET still supports ...

Get Practical Standards for Microsoft® Visual Basic® .NET, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.