1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 9 - Structured Error Handling

By , About.com Guide

3 of 10

Microsoft's Point of View

Here's what the Microsoft documentation says about it:

A Catch statement handles an exception that is of the same type as the type declared in the Catch statement, or of a type derived from it. If you supply a Catch statement that does not specify an exception type, it handles any exception derived from the Exception class.

A Catch statement, whether or not it specifies an exception type, can optionally include the When clause. When is followed by an expression that must be convertible to Boolean. The exception is handled only if it is of the right type and the When expression evaluates to True.

Translating, this says, "A Catch statement will handle the error in the As Exception clause unless the clause isn't there. Then the Catch statement will try to handle every exception. Therefore, if a When clause is used instead of As Exception, you have to be careful code the test correctly.

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Trapping Errors Using Structured Error Handling

©2009 About.com, a part of The New York Times Company.

All rights reserved.