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 / November 2005

Tip: Looking for answers? Try searching our database.

how do i add items in the drop down box using Visual basic?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mita - 15 Nov 2005 20:58 GMT
HI all
Can anyone tell me how do i use vb to add items in the dropdown box as i am
making a form and using control toolbox to create a drop down.
please Help!!!!!!!!!!!!
LEC - 15 Nov 2005 21:53 GMT
Hi there -
Is this what you are looking for?
Private Sub UserForm_Initialize()
   ComboBox1.AddItem "A"
   ComboBox1.AddItem "B"
   ComboBox1.AddItem "C"
   ComboBox1.AddItem "D"
   ComboBox1.AddItem "E"
   ComboBox1.AddItem "F"
End Sub

HTH
Lorraine
mita - 16 Nov 2005 22:07 GMT
Thanks a bunch for replying LEC....
ya it is wat im lookin for ..however i dont know much about vb..so if i m
using word for making forms where do i insert this code which u hav given
me?????..by double clicking the combo box and just adding the code??? correct
me if i m wrong
please help

cheers
mita

> Hi there -
> Is this what you are looking for?
[quoted text clipped - 9 lines]
> HTH
> Lorraine
LEC - 17 Nov 2005 00:07 GMT
Hi Mita,
You can double click on the combobox.  That will get you to the view
code window and the change event for the combobox.  You want to put
this code in the User Form Initialize event.  So when you double click
on the combobox you will see something like:

Private Sub Comboxbox1_Change()

End Sub

You don't want to put the code here.  You need to change to the user
form initialize event.  To do this you would select the left dropdown
box (this is where all the objects on your form are).  Select User Form
(its at the very bottom).  Once you select the user form your object
drop down should say User Form.  In the right drop down box, select
"Initialize" (if it is not already selected) .  Now in the code window
you should see.

Private Sub UserForm_Initialize()
' Put the code for the combobox here.
End Sub

I have indicated above where the code should go.

HTH

LEC
 
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.