O'Reilly logo

Visual Basic 2010 Unleashed by Alessandro Del Sole

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

Try..Catch..Finally

You perform exception handling writing a Try..Catch..Finally code block. The logic is that you say to the compiler: “Try to execute the code; if you encounter an exception, take the specified actions; whenever the code execution succeeds or it fails due to an exception, execute the final code.” The most basic code for controlling the execution flow regarding exceptions is the following:

image

IntelliSense does a great job here. When you type the Try keyword and then press Enter, it automatically adds the Catch statement and the End Try terminator. The ex variable gets the instance of the System.Exception that is caught and that provides ...

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