Chapter 12 Quick Reference


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 Ctrl

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

Create a new collection and add members to it

Declare a variable by using the New Collection syntax. Use the Add method to add members. For example:

Dim URLsVisited As New Collection() URLsVisited.Add(TextBox1.Text)

Use Visual Basic for Applications collections in Office applications

Open Word or another Office application (Excel, Access, PowerPoint, and so on). Click the Macros command on the Macro submenu of the Tools menu, give the macro a name, click Create, and then enter VBA macro code by using the Visual Basic Editor. Word exposes many useful collections, including Documents and Paragraphs.



Microsoft Visual Basic 2005 Step by Step
Microsoft Visual Basic 2005 Step by Step (Step by Step (Microsoft))
ISBN: B003E7EV06
EAN: N/A
Year: 2003
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net