Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2008

Tip: Looking for answers? Try searching our database.

How to populate a listbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Southern at Heart - 05 Feb 2008 04:21 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.