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

Chapter 9 - Structured Error Handling

By Dan Mabbutt, About.com

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

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

Easy ways to connect two computers for networking purposes. 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.