| 0-DropDown Combo | The user can type a new value into the control |
| 1-Simple Combo | Same as a DropDown Combo except the list is always visible |
| 2-DropDown List | Only items in the list can be selected. |
| List | ListIndex | ItemData |
| Chicago | 0 | 20 |
| Houston | 1 | 21 |
| Philadelphia | 2 | 22 |
| San Antonio | 3 | 23 |
| ItemData | The set of numbers that correspond to the items in the ComboBox. |
| List | Text strings for the items in the ComboBox. |
| ListCount | The number if items in the ComboBox. |
| ListIndex | The index of the item currently selected. |
| NewIndex | The index of the last item that was added to the ComboBox. |
| Sorted | States if the ComboBox is sorted. |
| Style | If the ComboBox has a drop-down list or a
permantly visible list. Also determines if the user can add a new value, or can only select from the preset values. |
| Text | The Text value of the item currently selected |
| List is the set of all values in the ComboBox. AddItem adds text items to the ComboBox. |
cboBox1.AddItem "Chicago" cboBox1.AddItem "Houston" cboBox1.AddItem "Philadelphia" cboBox1.AddItem "San Antonio" |
| ListCount is the number of items in the ComboBox. In this example, the ListCount is 4 |
x = cboBox1.Count x = 4 |
| ListIndex is the index of the selected item. If no item is selected, the ListIndex is -1 |
"Chicago (0)" "Houston (1)" "Philadelphia (2)" "San Antonio (3)" |
| Text is the value of the selected item. If the user selects the third item, the text will be "Philadelphia" |
str = cboBox.text str = "Philadelphia" |
| ItemData is a hidden value for each value in the ComboBox. ItemData can be used to store a key value while a more descriptive text value is displayed in the ComboBox. You cannot rely on the ListIndex to determine which text value was selected, especially if the list has been sorted. In the example on the right, each city has a code in the database. These are used as the ItemData values. NewIndex is the index of the item currently being added to the ComboBox. In this example, the NewIndex value is replaced with the city code and set as the ItemData value. |
cboBox.AddItem "Chicago" cboBox.ItemData(cboBox.NewIndex) = 20 cboBox.AddItem "Houston" cboBox.ItemData(cboBox.NewIndex) = 21 cboBox.AddItem "Philadelphia" cboBox.ItemData(cboBox.NewIndex) = 22 cboBox.AddItem "San Antonio" cboBox.ItemData(cboBox.NewIndex) = 23 |