Returns or sets the number or string that uniquely identifies an object in a collection.
Index returns or sets the number that uniquely identifies a control or form in an array. Available only if the control or form is part of a control or form array.
Object.Index [ = value ]
Object.Key [ = value ]
Object:Form, Animation, Button, CheckBox, ColumnHeader, ComboBox, Command, Frame, Image, Label, ListBox, ListImage, ListItem, ListView, MenuItem, MonthView, Node, Option, Panel, Progress, RichEdit, Scroll, Slider, Tab, TabStrip, Textbox, Timer, TrayIcon, TreeView, UpDown Object
Ocx Array - For an Ocx control or form the Index property returns a number that uniquely identifies the object in a control or form array.
The control or form array is a group of controls or forms that share common names, types, and event procedures. Each control or form has a unique index. When a control or form in the array recognizes an event, it calls the event procedure for the group and passes the index as an argument, allowing your code to determine which control or form recognized the event. For example:
OpenW 44
Ocx Command cmd(1) = "But1", 10, 10, 50, 20
Ocx Command cmd(289) = "But289", 10, 40, 50, 20
Print Form(44).Index // = 0 Doesn't return 44 as expected
Print cmd(289).Index // = 289
Do : Sleep : Until Form(44) Is Nothing
Sub cmd_Click(Index%)
Message "Index No:" & Index% & #13#10 & "Form Index:" & Me.Index
EndSub
Collections - For collections the Index property returns the value of the order of the object in the collection. The Index property is set by default to the order of the creation of objects in a collection. The index for the first object in a collection will always be one (1). The order of an object can change when objects in the collection are reordered, such as when you set the Sorted property to True. If you expect the Index property to change dynamically, it may be more useful to refer to objects in a collection by using the Key property.
The Key property returns or sets a string that uniquely identifies a member in a collection. You can set the Key property when you use the Add method to add an object to a collection, but you can change the name afterwards.
Global Enum sbrText = 0, sbrFlat, sbrRaise, sbrCaps, sbrNum, sbrScroll, sbrIns, sbrDate
Dim p As Panel
Ocx StatusBar sb
sb.Panels.Add , "Part1", "Part 1", sbrText
sb.Panels.Add , "Caps", "Caps", sbrCaps
sb.Panels.Add , "Num", "Num", sbrNum
sb.Panels.Add , "Scroll", "Scroll", sbrScroll
sb.Panels.Add , "INS", "INS", sbrIns
sb.Panels.Add , "Date", "c", sbrDate
sb.Item("Date").Text = "AM/PM"
For Each p In sb
Print p.Key, p.Index
Next
Form, Animation, Button, CheckBox, ColumnHeader, ComboBox, Command, Frame, Image, Label, ListBox, ListImage, ListItem, ListView, MenuItem, MonthView, Node, Option, Panel, Progress, RichEdit, Scroll, Slider, Tab, TabStrip, Textbox, Timer, TrayIcon, TreeView, UpDown
{Created by Sjouke Hamstra; Last updated: 10/10/2014 by James Gaite}