Dealing with run-time errors

There are many situations that can generate run-time errors: careless programming, system errors and so on. Any run-time error will have stop the script - not usually desirable.

Here's a general way of dealing with this problem:

On Error Resume Next

[Some statement or call to another procedure]

If Err.Number Then

MsgBox Err.Description 

Err.Clear 

End If

It works by making use of a global object called Err that is part of VBScript. By stating that "On Error Resume Next" VBScript knows that you want to deal with any errors rather than letting VBScript deal with them in it's own way (i.e. to halt the script).