Visual Basic: Windows Controls

Buttons Collection

See Also    Example    Properties    Methods    Events

A Buttons collection is a collection of Button objects for a Toolbar control.

Syntax

toolbar.Buttons(index)

*toolbar.*Buttons.Item(index)

The Buttons collection syntax has these parts:

Part Description
toolbar An object expression that evaluates to a Toolbar control.
index An integer or string that uniquely identifies the object in the collection. The integer is the value of the Index property; the string is the value of the Key property.

Remarks

The Buttons collection is a 1-based collection, which means the collection's Index property begins with the number 1 (versus 0 in a 0-based collection).

Each item in the collection can be accessed by its index or unique key. For example, to get a reference to the third Button object in a collection, use the following syntax:

Dim btnX As Button
   ' Reference by index number.
Set btnX = Toolbar1.Buttons(3) 
   ' Or reference by unique key.
Set btnX = Toolbar1.Buttons("third") ' Assuming Key is "third."
   ' Or use Item method.
Set btnX = Toolbar1.Buttons.Item(3)