VBScript » Statements » With...End With

Version: 5.0

With object
 any legal code
End With

The With statement allows you to execute code on the named object. It is very important to understand that you can only specify a single object to be acted upon. You cannot list several objects.

You can nest With statements inside of other With statements or inside other conditional statements, such as an If Else. However, do not jump into or out of With ... End With blocks of code. The problem is that either the With or End With portion of the statement may not be executed and this could cause errors or generate erroneous results.

Between the object name and End With, you may place any legal block of VBScript code. For example, you could place statements assigning values to the properties of the designated object, as shown below.


With CatObject
Rem assign properties
.CatName = "Amy"
.CatAge = 3
.CatColor = "black, orange, white"
End With
Language(s): VBScript

See Also: