Data Access  «Prev 

Handling errors using VBScript

src="images/one-error2.gif" width="404" height="305" layout="responsive" alt="One Error">
One Error
  1. The On Error Resume Next statement tells VBScript to resume program execution on the line immediately following the one where the error occurred. Without this, the program would just crash. If an error occurs on any line following this statement, then VBScript will continue with the next program statement.
  2. When a runtime error occurs, information about the error is stored in the VBScript Err object. You can use this information in conjunction with the On Error Resume Next statement to handle error conditions intelligently. In this example, error handler code is passed information about the error.
  3. This function is called when the Err object's number property does not equal zero, which indicates an error. This example simply displays information about the error. You can write much more sophisticated code to take some action, depending on the error.