Vbscript.. On error Goto

amcurso
amcurso used Ask the Experts™
on
Hi. Good Day to all. I have this problem. How can i do this in vbscript? I know this works in vb 6.

On Error Goto ErrHandler
 statement1 ' this is the line having an error
 statement2.
      .
      .
      .
 statementN

ErrHandler:
  statements if error has occured

thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
in vbscript, you only have the on error resume next.
and after each critical statement, check err.number
Top Expert 2006
Commented:
VBScript doesn't have this kind of error handler mechanism. It has only

On Error Resume Next
On Error GoTo 0

i.e. to tolerate the error. You need to then test error after every possible statement using

If Err.Number <> 0 then

http://www.microsoft.com/technet/scriptcenter/resources/scriptshop/shop1205.mspx

Author

Commented:
Thanks. i just realized that. sigh... :-(

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial