The VBScript Network and Systems Administrator's Cafe

Jun 18 2008   1:14PM GMT

VBScript Statements: Explanation of the Exit statement

Jerry Lees Jerry Lees Profile: Jerry Lees

The Exit statement in vbscript allows you to exit a block of code, in the case of a subroutine (Exit Sub) or a function (Exit Function), or the entire script.

This statement is assumed at the end of a script, and therefore is not required, but is typically used in conditional statements to exit a section of code when a particular condition is met.

 Below is an example:


sub mysub(testvar)
    testvar=testvar + 1
    if testvar =2 then
        exit sub
        wscript.echo testvar
end sub

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: