In this lesson, I’ll tell you about the ComboBox control in brief.
ComboBox is the combination of a TextBox and a ListBox. The user can type in the text field to select an item or select an item manually from the list. All the properties, events and methods of a ComboBox control are as same as the ListBox control. So the discussion of ListBox control in previous lessons also applies for ComboBox control.
Styles of ComboBox
There are three styles of ComboBox controls– Dropdown Combo, Simple Combo and Dropdown List. You can change/select the style from the Style property of ComboBox.
Example
ComboBox program to select an item from the list
Private Sub cmdSelectBirthYear_Click() Print "Your year of birth is" & cboBirthYear.Text End Sub Private Sub Form_Load() For i = 1980 To 2012 cboBirthYear.AddItem Str(i) 'Str function returns the 'string representation of a number i = Val(i) Next i End Sub
See the attached example combobox.zip to examine the code in your own IDE.