I have combobox1, commandbutton1, & listbox1
combobox1 has a list of items in it. I want to put code in the click event
of commandbutton1 so that the user can select an entry from combobox1, click
the button, and it will be added to the list in listbox1. I know this must
be easy, but I've never done this type of thing before...
thanks.
Southern@Heart
Doug Robbins - Word MVP - 05 Feb 2008 04:46 GMT
Use
If ComboBox1.ListIndex > -1 Then
ListBox1.AddItem ComboBox1.Text
ComboBox1.ListIndex = -1
End If
The ListIndex of the combobox is reset to -1 (nothing selected) so that an
inadvertent double click on the button would not result in the item being
added a second time.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
>I have combobox1, commandbutton1, & listbox1
> combobox1 has a list of items in it. I want to put code in the click
[quoted text clipped - 6 lines]
> thanks.
> Southern@Heart
Southern at Heart - 05 Feb 2008 04:50 GMT
I'm also needing to add a commandbutton to remove an item from the listbox if
I person changes their mind. Can you just highlight any item in there and
remove it?
thanks
> I have combobox1, commandbutton1, & listbox1
> combobox1 has a list of items in it. I want to put code in the click event
[quoted text clipped - 3 lines]
> thanks.
> Southern@Heart
Greg Maxey - 05 Feb 2008 05:03 GMT
Private Sub CommandButton1_Click()
With Me.ListBox1
.RemoveItem .ListIndex
End With
End Sub

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
> I'm also needing to add a commandbutton to remove an item from the
> listbox if I person changes their mind. Can you just highlight any
[quoted text clipped - 9 lines]
>> thanks.
>> Southern@Heart