O'Reilly logo

Professional Visual Basic® 2008 by Bill Sheldon, Kent Sharkey, Bill Evjen, Billy Hollis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Exception Handling and Debugging

All professional-grade programs need to handle unexpected conditions. In programming languages before Microsoft .NET, this was often called error handling. Unexpected conditions generated error codes, which were trapped by programming logic that took appropriate action.

The common language runtime in .NET does not generate error codes. When an unexpected condition occurs, the CLR creates a special object called an exception. This object contains properties and methods that describe the unexpected condition in detail and provide various items of useful information about what went wrong.

Because the .NET Framework deals with exceptions instead of errors, the term error handling is seldom used in the .NET world. Instead, the term exception handling is preferred. This term refers to the techniques used in .NET to detect exceptions and take appropriate action.

This chapter covers how exception handling works in Visual Basic 2008. It discusses the common language runtime (CLR) exception handler in detail and the programming methods that are most efficient in catching errors. Specifically, it covers the following:

  • A very brief overview of error handling in Visual Basic 6 (VB6), for those just moving to .NET

  • The general principles behind exception handling

  • The Try...Catch...Finally structure, the Exit Try statement, and nested Try structures

  • The exception object's methods and properties

  • Capabilities in Visual Studio for working with exceptions

  • Error and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required