There are several ways to handle errors in your Visual Basic applications. The
simplest but least effective way is not to do anything. Let the errors occur. Windows will
generate error messages to the user, and the application will shut down. A better way to
handle errors is to trap the errors with the Visual Basic statement On Error. By coding On
Error, you are handling errors in a more graceful manner.
You have the option of trying to correct the problem through code, to bypass
the code that caused the error, or to shut down the application if the error is unrecoverable.
This section discusses the On Error statement and the different ways of using
it in procedures. The discussion examines inline error handling and error-handling routines found
at the end of procedures. Some trappable errors will also be covered with recommendations on
how to use them and what to look for in code.