Promotic

On Error - statement of language VBScript

Description:
It allows error-handling.
Syntax:
On Error Resume Next
Note:
If you don't use an On Error Resume Next statement, then any runtime error that occurs is fatal; i.e. an error message is displayed and the execution stops.
On Error Resume Next causes execution to continue with the statement immediately following the statement that caused the runtime 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 runtime error. You can then build the error-handling routine inline within the procedure. An On Error Resume Next statement becomes inactive if 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 VBScript Err object can be used for detecting the error and its description. The usage is demonstrated in an example.

For similar purpose in the JavaScript language is used the statement try...catch.
See also:
Example:
On Error Resume Next
Dim a, b
a = 0
b = 1/a 'Division by zero !!
If Err.Number <> 0 Then
  MsgBox("Error=" & Err.Number & " Description=" & Err.Description)
  Err.Clear
End If
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.