itdrms is right.
Omitting any On Error Resume Statement will stop VBScript continuing, and upon any error, it will crash out with the error message.
The only way to do it in a user friendly manner is to use the code itdrms provided, at a place where you expect an error may occur.
Regards,
Rob.
Main Topics
Browse All Topics





by: itdrmsPosted on 2007-10-03 at 20:52:05ID: 20011686
Nope, sorry. Only 2 options with VBS -- handle each possible error or ignore all errors. GoTo 0 is the only GoTo option -- it doesn't really mean the same as a GoTo to redirect -- but totally understand what you're attempting. It just means the opposite of resume next, instead of continuing it throws an ugly error to the user.
There are limitations/tradeoffs for not having a full blown compiler.
The only good thing is that the On Error is not a one time statement. You can switch back in forth in your script.
If there's a particular place in code you are concerned with you can turn Resume Next on just before and turn it off after, otherwise it gets pretty laborious. No nice global catches.
On Error Resume Next
AvgResult = a/b
If Err.Number > 0
WScript.Quit
End If
On Error GoTo 0