Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to terminate execution early? 1

Status
Not open for further replies.

tichtich

Programmer
Jul 11, 2005
2
GB
Hello. I'm new to VBScript, writing a script to run with Windows Scripting Host.

In the event of an error in my input stream I want to simply display a message and stop execution immediately. I don't want to bother with passing control back up to higher-level subroutines. There doesn't seem to be a STOP statement like I remember from earlier forms of BASIC that I used many years ago. Is there some other way to do it?

Sorry for such a newbie question! Any help would be much appreciated.
 
[tt]
sub xyz(abc)
[blue]on error resume next[/blue]
'...etc...
'at judicious location where you need to conrol
if err.number<>0 then
wscript.echo hex(err.number& vbcrlf & err.description
[blue]wscript.quit[/blue]
end if
'... etc...
end sub
[/tt]
 
Thanks very much, Tsuji. That's just what I needed.
 
Thanks! (I had a typo you should have noticed and made right [tt]hex(err.number[red])[/red][/tt]).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top