hey, can any one tell me somewhere, where i can find some thing that explains how to use combo boxes, not anything with API or stuff like that, just the basics
thanks
Printable View
hey, can any one tell me somewhere, where i can find some thing that explains how to use combo boxes, not anything with API or stuff like that, just the basics
thanks
I usually prefer to set the style of a combobox to '2 - Dropdown List'.
You can add items to a combo with the combo's AddItem method, for example:
You can get the currently selected item from a combo with its Text property:Code:Private Sub Form_Load()
' Using a combobox named Combo1 with its Style set to 2.
With Combo1
.AddItem "Belgium"
.AddItem "Canada"
.AddItem "Denmark"
.AddItem "England"
.AddItem "France"
' Set the ListIndex so that the first item in the combo is selected/displayed.
.ListIndex = 0
End With
End Sub
If for some reason you want to examine all the values in a combo you can use the ListCount property of the combo to see how many items and the List property to get at the items, for example:Code:Private Sub Command1_Click()
MsgBox Combo1.Text
End Sub
PaulCode:Private Sub Command2_Click()
Dim intIndex As Integer
Dim strMsg As String
For intIndex = 0 To Combo1.ListCount - 1
strMsg = strMsg & Combo1.List(intIndex) & vbCrLf
Next intIndex
MsgBox strMsg, , ""
End Sub