Microsoft Office Tutorials and References
In Depth Information
Understanding Objects and Collections
Listing 4-8: Using a With myCtl…End With Block to Change a
Dim myCtl As Control
Set myCtl = myForm.[Selling Price]
.Visible = True
.SpecialEffect = Flat
.FontBold = True
.Value = 1.1 * myCtl
The With...End With block changes the Visible property of the Selling
Price control to True, sets its Special Effect property to Flat, sets its
font to bold, and increases the value stored in that field by 10 percent.
As in the case of the For Each...Next loop, the With...End With
statement is optional — not something that you must use in any code you write.
Our main purpose is to take the mystery out of it in case you should ever
come across With...End With in someone else’s code.