Executes a series of statements on a single object or a user-defined type.
With object
[statements]
End With
object: Name of an object or a user-defined type.
The With statement allows you to perform a series of statements on a specified object without requalifying the name of the object. For example, to change a number of different properties on a single object, place the property assignment statements within the With control structure, referring to the object once instead of referring to it with each property assignment.
With can be used up to 64 levels deep. However, there is no way to access a higher leveled object, unless the object is fully named.
A With structure is closed with End With.
After executing the Ocx or OcxOcx command, With is implicitly invoked and the properties and methods of the Ocx are accessible without naming the object. The With is valid until the next Ocx or OcxOcx command.
Ocx Label MyLabel = "", 10, 10
With MyLabel
.Height = 18
.Width = 200
.Caption = "This is MyLabel"
End With
Do : Sleep : Until Me Is Nothing
The example illustrates use of the With statement to assign values to several properties of the same object.
Ocx StatusBar StatusBar1
Dim tmpP As Panels
Set tmpP = StatusBar1.Panels
With StatusBar1
Print .Width
With .Panels
Print .Count
EndWith
EndWith
Set tmpP = Nothing
Do : Sleep : Until Me Is Nothing
{Created by Sjouke Hamstra; Last updated: 25/10/2014 by James Gaite}