VBScript » Statements » OnError

Version: 1.0

Syntax:
<%On Error Resume Next%>
<%On Error GoTo 0%>

The On Error Resume Next statement gives you a limited amount of error handling control by preventing program interruptions from runtime errors. When an error occurs, by using this statement, the line of code containing the error is simply skipped over and the program continues running.

Examples

Code:
<% On Error Resume Next %>
Explanation:

Note that the error is not corrected, just ignored, and an error message is not displayed. Of course, your program may still crash or give erroneous output if the error involves a value required to successfully execute later portions of your code.

Language(s): VBScript
Code:
<% On Error GoTo 0 %>
Explanation:

The On Error GoTo 0 statement is used to disable error handling.

Language(s): VBScript
Code:
<% If Err.Number <> 0 Then %>
<% =Err.Number%>
<% Err.Clear %>
<% End If %>
Explanation:

If you wish to know whether an error has occured and of what type, you can insert this code.

Language(s): VBScript

See Also: