creating listbox values

creating listbox values

Post by Lighthous » Wed, 23 Mar 2005 01:33:49


I am new to using Userforms in my templates. I am trying to build one
that contains some listbox controls, but can't find out any info on how
to populate the lists.

I have the userform open and i click on the listbox control in my
toobox and place it on the userform. I can't directly add anything into
the control, nor will it let me enter anything into the "Value" field.
"Help" is useless, as usual. Can some one point me to a useful
tutorial? TIA
 
 
 

creating listbox values

Post by Jonathan W » Wed, 23 Mar 2005 02:50:08


Hi Lighthouse

Yiou have to populate the listbox with code. The simplest approach is to
include something like this in the UserForm_Initialize event of your form

ListBox1.List = Array("Joe", "Fred", "Bill", "Mike")


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

 
 
 

creating listbox values

Post by Lighthous » Wed, 23 Mar 2005 03:34:48

Jonathan, where do I find this "UserForm_Initialize" event or do i have
to create it somehow? Sorry if this sounds like a simpleton question.
When I dbl-click on the list box I get put into the code view for
Private sub listbox click (). I don't think I want to be there.
 
 
 

creating listbox values

Post by Jonathan W » Wed, 23 Mar 2005 03:40:32


Open the code window for the userform. In the left-hand dropdown box aboive
the code windows, select "UserForm". Then in the right dropdown, select
Initialize.

The following will be placed into the main code window

Private Sub UserForm_Initialize()

End Sub


Put your code between those two statements


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
 
 

creating listbox values

Post by Lighthous » Wed, 23 Mar 2005 05:37:03

not sure what's up w/ 'groups'. i replied to this a while ago and
haven't seen it show up yet. sorry if this is a dupe.

Jonathan, thanks for your answer, but WHERE do I find this
"UserForm_Initialize" event or do I have to create it myself. If I need
to create it, where and how do I do that? Sorry if this is a simpleton
question, but my knowledge of userforms is in its infancy.
 
 
 

creating listbox values

Post by Deb » Thu, 21 Apr 2005 01:30:07

I am a newbie with a question about my form. I populate my combobox
using this code;

cmboBusGroup.List() = Array("Brecksville", "Chicago", "Ritterhude")

What do I need to add so that in the future the user can add to the
list themself? For example, if the user wants to add "London" I would
like to have the user click a button (or something) to "Add BusGroup"
and add "London" without having to call me to add it in the code.

How do I do this?

Thank you!
Debbie