The VBScript Network and Systems Administrator's Cafe

Jul 23 2008   3:10PM GMT

VBScript Statements: Explanation of the With … End With Statement

Jerry Lees Jerry Lees Profile: Jerry Lees

The With … End With statement allows you to execute a section of code on a specific object or class that calls methods or set properties on the object from within VBScript without referencing the object directly in the code written.

It is a way of simplifying your code, and very useful in large scripts.
For example:

(please note, these examples are snippets of code and will not work by themselves in an editor)

with objSomething
     .FirstName = “Jerry”
     .LastName = “Lees”
     .URL = “
     .XBoxLiveTag = “CrashSerious”
     .Email = “Not-a-chance-spammers”
End with

This would be equivalent to the following standard code:

     objSomething.FirstName = “Jerry”
     objSomething.LastName = “Lees”
     objSomething.URL = “
     objSomething.XBoxLiveTag = “JLees”
     objSomething.Email = “Not-a-chance-spammers”

 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: