Chapter 12 Working with Collections 311
Chapter 12 Quick Reference
To Do This
Process objects in
a collection
Write a For Each... Next loop that addresses each member of the collection
individually. For example:
Dim ctrl As Control
For Each ctrl In Controls
ctrl.Text = "Click Me!"
Next
Move objects in the
Controls collection
from left to right
across the screen
Modify the Control.Left property of each collection object in a For
Each... Next loop. For example:
Dim ctrl As Control
For Each ctrl In Controls
ctrl.Left = ctrl.Left + 25
Next
Give special
treatment to an
object in a collection
Test the Name property of the objects in the collection by using a For
Each... Next loop. For example:
Dim ctrl As Control
For Each ctrl In Controls
If ctrl.Name <> "btnMoveObjects" Then
ctrl.Left = ctrl.Left + 25
End If
Next