If an error does occur, Internet Explorer stores the error information in the Err object. If another error occurs, the Err object will be updated with the new error, and the old error will be overwritten.
To turn off error handling, use the statement On Error GoTo 0 . Internet Explorer will revert to the default error handling behavior and display the error message to the user .
NoteVBScript does not support the On Error GoTo < label > statement, and you cannot write an error handler that is called automatically when an error occurs. Therefore, you must implement inline error handling to check for an error after each statement that can cause an error.
To retrieve information about the error, check the Description property.
When an error occurs, the Err object contains the error information until another error occurs. If a statement runs successfully, the Err object is not cleared. Therefore, after an error occurs, clear the error by invoking the Clear method of the Err object.
Example
This example shows the general syntax for handling errors:Sub cmdSubmit_OnClick On Error Resume Next 'Statement that might cause an error If Err <> 0 Then Msgbox "An error occurred. " & Err.Description Err.Clear End if 'Statement that might cause an error If Err <> 0 Then Msgbox "An error occurred. " & Err.Description Err.Clear End if End SubTo test your own error-handling code, you can purposely cause an error by using the Raise method of the Err object.
VBScript does not use all available numbers for its errors. If you want to generate your own errors, begin a numbering scheme with 65535 (the highest value supported) and work your way down.
Example
This example would cause a custom error numbered 65000 to be raised:Err.Raise 65000