Visual Basic 2005 with .NET 3.0 Programmer's Reference

The On Error statement controls error handlers in Visual Basic classic error handling. You can use structured and classic error handling in the same program but not in the same routine.

The following list briefly describes the On Error statement’s four variations:

Visual Basic provides four ways to exit error-handling mode:

Using On Error GoTo -1 to end error-handling mode can be very confusing because it’s hard to tell when the program is in error-handling mode and when it isn’t. Usually, the code is easier to understand if all of the error-handling code is grouped at the end of the routine and if each block of error-handling code ends with one of the other methods (Exit Sub, Exit Function, Resume, or Resume Next).

Категории