How do I select the item in the ComboBox. The selected item will determine what will be inserted in ComboBox2.
Printable View
How do I select the item in the ComboBox. The selected item will determine what will be inserted in ComboBox2.
you could use this
let me know if thats not what you wantedCode:private sub command1_click
dim item as string
item = combo1.text
combo2.additem string
end sub
the .ListIndex property moves to an entry
combo1.List(x) property returns the text.
combo1.list(combo1.listindex) returns the selected item.
I think something like this is what he wants.
Combo1.ListIndex = 2
Where should I put these codes?
in the Combo1_Click? or Combo2_Click?
when combo1 item is selected, it will determine the items to be added into combo2.
my bad the code i posted above should be this
this code would be used with a command button but you could change it to whatever you wanted.Code:private sub command1_click
dim item as string
item = combo1.text
combo2.additem item
end sub
Or :
VB Code:
Private Sub Combo1_Click() Combo2.AddItem Combo1.List(Combo1.ListIndex) End Sub
OK, now I really think I see what you want.
VB Code:
Private Sub Combo1_Click() Combo2.AddItem Combo1.List(Combo1.ListIndex) End Sub
VB Code:
Private Sub Form_Load() Combo1.AddItem = Hello Combo1.AddItem -Goodbye End Sub Private Sub Combo1_Click() Select Case Combo1.Text Case "Hello" MsgBox ("Hello") Case "Goodbye" MsgBox ("Goodbye") End Select End Sub
What's with the = and - ? They aren't needed... They are wrong ;)Quote:
Originally posted by Madboy
VB Code:
Private Sub Form_Load() Combo1.AddItem = Hello Combo1.AddItem -Goodbye End Sub Private Sub Combo1_Click() Select Case Combo1.Text Case "Hello" MsgBox ("Hello") Case "Goodbye" MsgBox ("Goodbye") End Select End Sub
- was a mistake, and i couldnt remember the syntax off the top of my head regarding the =.
The general Select Case code is a nice clean working example, he can remove my errors now.:blush: