Bookshelf Home | Contents | Index | PDF |
Siebel VB Language Reference > VB Language Reference > On Error StatementThis standard VB statement specifies the location of an error-handling routine within the current procedure. SyntaxOn Error {GoTo label | Resume Next | GoTo 0} ReturnsUsageOn Error is used to provide routines to handle specific errors. On Error can also be used to disable an error-handling routine. Unless an On Error statement is used, any run-time error is fatal; that is, Siebel VB terminates the execution of the program. An On Error statement includes one of the following parts: When it is referenced by an On Error GoTo label statement, an error handler is enabled. When this enabling occurs, a run-time error results in program control switching to the error-handling routine and "activating" the error handler. The error handler remains active from the time the run-time error has been trapped until a Resume statement is executed in the error handler. If another error occurs while the error handler is active, Siebel VB searches for an error handler in the procedure that called the current procedure (if this fails, Siebel VB looks for a handler belonging to the caller's caller, and so on). If a handler is found, the current procedure terminates, and the error handler in the calling procedure is activated. NOTE: Because Siebel VB searches in the caller for an error handler, any additional On Error statements in the original error handler are ignored. Executing an End Sub or End Function statement while an error handler is active is an error (No Resume). The Exit Sub or Exit Function statement can be used to end the error condition and exit the current procedure. ExampleThis example prompts the user for a drive and folder name and uses On Error to trap invalid entries. Sub Button_Click See AlsoErl Function |
Siebel VB Language Reference |