Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

VBScript On Error Statement

Enables error-handling.

Syntax: VBScript On Error Statement

On Error Resume Next

Remarks: VBScript On Error Statement

If you don't use an On Error Resume Next statement, any run-time error that occurs is fatal; that is, an error message is displayed and execution stops.

On Error Resume Next causes execution to continue with the statement immediately following the statement that caused the run-time error, or with the statement immediately following the most recent call out of the procedure containing the On Error Resume Next statement. This allows execution to continue despite a run-time error. You can then build the error-handling routine inline within the procedure. An On Error Resume Next statement becomes inactive when another procedure is called, so you should execute an On Error Resume Next statement in each called routine if you want inline error-handling within that routine.

The following example illustrates use of the On Error Resume Next statement:

On Error Resume Next

Err.Raise 6   ' Raise an overflow error.

MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description

Err.Clear   ' Clear the error.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.