Exception and Error Handling in Visual Basic
Visual Basic supports structured exception (error) handling, which allows the program to detect and possibly recover from errors during execution. Visual Basic uses an enhanced version of the Try...Catch...Finally syntax already supported by other languages such as C++. Structured exception handling combines a modern control structure (similar to Select Case or While) with exceptions, protected blocks of code, and filters.
Structured exception handling, which is the recommended method of error handling in Visual Basic, makes it easy to create and maintain programs with robust, comprehensive error handlers. Unstructured exception handling using On Error can degrade application performance and result in code that is difficult to debug and maintain.
In This Section
Introduction to Exception Handling (Visual Basic)
Summarizes how to handle exceptions in your programs.Choosing When to Use Structured and Unstructured Exception Handling (Visual Basic)
Describes both types of exception handling and suggests when they are most appropriate.Types of Errors (Visual Basic)
Provides an overview of syntax errors, run-time errors, and logic errors.Configuring Warnings in Visual Basic
Details how to turn compiler warnings on and off in Visual Basic.Structured Exception Handling Overview for Visual Basic
Discusses and demonstrates structured exception handling in Visual Basic.Unstructured Exception Handling Overview (Visual Basic)
Discusses and demonstrates unstructured exception handling in Visual Basic.
Related Sections
Generate From Usage
Describes how to generate a stub for an undefined class, constructor, method, property, field, or enum.Debugger Roadmap
Discusses the fundamentals of using the Visual Studio debugger. Topics include debugging basics, execution control, attaching to a running program, Just-In-Time debugging, launching the debugger automatically, dumps, breakpoints, inspecting your program, handling exceptions, Edit and Continue, and using expressions in the debugger.Just-In-Time Debugging
Describes just-in-time debugging, a feature that launches the Visual Studio debugger automatically when a program running outside Visual Studio encounters a fatal error.Debugging Managed Code
Covers common debugging problems and techniques for managed applications.Exception Assistant
Describes the Exception Assistant feature, which facilitates troubleshooting run-time errors.Edit and Continue
Describes Edit and Continue, a time-saving feature that allows you to make changes to source code while the program is in break mode.COM and ActiveX Debugging
Provides tips on debugging COM applications and ActiveX controls.