With Statement Example

This example uses the With statement to execute a series of statements on a single object. The object MyObject and its properties are generic names used for illustration purposes only.

With MyObject
    .Height = 100        ' Same as MyObject.Height = 100.
    .Caption = "Hello World"    ' Same as MyObject.Caption = "Hello World".
    With .Font
        .Color = Red        ' Same as MyObject.Font.Color = Red.
        .Bold = True        ' Same as MyObject.Font.Bold = True.
    End With
End With