Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox and Command Button

Status
Not open for further replies.

suchis

MIS
Jun 6, 2003
8
0
0
BM
I would like to know the code for Selecting an Item from VB ComboBox and use a Command button to manipulate the selected item.
 
MsgBox Combo1.list(Combo1.ListIndex) will display the item in the ComboBox that you click on.

What do you mean by "manipulate the selected item"?

Experience is something you don't get until just after you need it.
 
Sorry, should have explained that you need to put the code in the click event of the combobox.

Experience is something you don't get until just after you need it.
 
Put a combobox, a command button, and a textbox on a form then ...
form_load()
combo1.additem = "dog"
combo1.additem = "cat"
combo1.additem = "fish"
combo1.additem = "mouse"
end sub

command1_click()
text1.text = combo1.text
end sub


 
vbrocks, that won't work.



Experience is something you don't get until just after you need it.
 
bigalbigal
Which bit of it doesn't work for you?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
johnwm
>Which bit of it doesn't work for you?

You can't use the = sign when adding items.

The Command button works but requires 2 user inputs instead of just 1:

Private Sub Combo1_Click()
Text1 = Combo1.List(Combo1.ListIndex)
End Sub


Experience is something you don't get until just after you need it.
 
Sorry about that....

In form_load() event
combo1.additem "dog"
combo1.additem "cat"
combo1.additem "fish"
combo1.additem "mouse"
end sub

In command1_click() event
text1.text = combo1.text
end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top