VBScript Statements: Explanation of the With … End With Statement
Posted by: 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 = “http://www.gamersigs.net”
.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 = “http://www.gamersigs.net”
objSomething.XBoxLiveTag = “JLees”
objSomething.Email = “Not-a-chance-spammers”




