O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

With Statement

Syntax

With object
   [statements]
End With
object

Use: Required

Data Type: Object

A previously declared object variable.

statements

Use: Optional

Program code to execute against object.

Description

Performs a set of property assignments and executes other code against a particular object, thus allowing you to refer to the object only once. Because the object is referred to only once, the “behind the scenes” qualification of that object is also performed only once, leading to improved performance of the code block.

Rules at a Glance

  • The single object referred to in the With statement remains the same throughout the code contained within the With...End With block. Therefore, only properties and methods of object can be used within the code block without explicitly referencing the object. All other object references within the With...End statement must start with a fully qualified object reference.

  • With statements can be nested, as long as the inner With statement refers to a child object or a dependent object of the outer With statement.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required