De: Rob Bovey Objet: Re: How do I populate a List Box with an array? Date : jeudi 23 septembre 1999 02:36 Hi tom, I've rearranged your code below so that it will work in a Userform with 3 listboxes. Option Explicit Option Base 1 dim Hoursarray(12, 1) As Integer dim Minutesarray(4, 1) As Integer dim TimeIndicatorarray(2, 1) As String ' Defines and fills the Hoursarray. Sub Fillarrays() dim counter As Integer for counter = 1 to 12 Hoursarray(counter, 1) = counter next Minutesarray(1, 1) = 0 Minutesarray(2, 1) = 15 Minutesarray(3, 1) = 30 Minutesarray(4, 1) = 45 TimeIndicatorarray(1, 1) = "AM" TimeIndicatorarray(2, 1) = "PM" end Sub Private Sub Userform_Initialize() Fillarrays ListBox1.List = Hoursarray ListBox2.List = Minutesarray ListBox3.List = TimeIndicatorarray end Sub -- Rob Bovey, MCSE, MCSD The Payne Consulting Group http://www.payneconsulting.com * Please post all responses to this newsgroup * * I delete all unsolicited e-mail messages * Thomas M wrote in message news:MPG.1252ec604832247c98968e@msnews.microsoft.com... > I have the following code (I've included the comments) to define and fill > 3 arrays. > > ' The default base for an array is 0, meaning that a 10-element > ' array would be indexed from 0-9. Changing the base to 1 causes > ' the array to be indexed from 1-10, which is more intuitive. > > Option Base 1 > > ' Defines and fills the Hoursarray. > > Sub Fillarrays() > dim Hoursarray(12, 1) As Integer > dim Minutesarray(4, 1) As Integer > dim TimeIndicatorarray(2, 1) As String > dim counter As Integer > for counter = 1 to 12 > Hoursarray(counter, 1) = counter > next > Minutesarray(1, 1) = 0 > Minutesarray(2, 1) = 15 > Minutesarray(3, 1) = 30 > Minutesarray(4, 1) = 45 > TimeIndicatorarray(1, 1) = "AM" > TimeIndicatorarray(2, 1) = "PM" > end Sub > > When I run the code, I don't get any errors, so I assume it's working. > The next step is to use these arrays to populate some list boxes in a > dialog box. I have one list box for the Hoursarray, one for the > Minutesarray, and one for the TimeIndicatorarray. This is where I get > stuck. How do I get my list boxes to display the contents of the > corresponding arrays? then how do I take what the user selects from the > list boxes and return that back to the worksheet? > > Thanks for any help you can offer. > > -- > > Please reply to the newsgroup so that all may learn > from your wisdom. > > --tom