Ask Experts Questions for FREE Help !
Ask
    vitaming's Avatar
    vitaming Posts: 1, Reputation: 1
    New Member
     
    #1

    Oct 18, 2009, 07:28 AM
    Display array in list box
    Hi all,

    How do I display a whole array in one list box? (I want it to be displayed in the form load event... is that possible?)
    For example I want to display these:

    ============================
    mstrMonths(0) = "January"
    mstrMonths(1) = "February"
    mstrMonths(2) = "March"
    mstrMonths(3) = "April"
    ============================
    in a list box.

    I tried doing this:
    ================================================== ======
    lstMonths.Text = mstrMonths(0) & vbNewLine & mstrMonths(1) & vbNewLine & _
    mstrMonths(2) vbNewLine & mstrMonths(3)
    ================================================== ======
    and it didn't work.
    Perito's Avatar
    Perito Posts: 3,139, Reputation: 150
    Ultra Member
     
    #2

    Oct 19, 2009, 03:10 PM
    In VB6, you would do this:

    lstMonths.Clear
    lstMonths.AddItem ("January")
    lstMonths.AddItem ("February")
    ...

    or, if filling from an array
    lstMonths.Clear
    for I = 0 to 11
    lstMonths.AddItem(strMonths(I))
    next I

    In VB.NET, you would do this:

    lstMonths.Items.Clear
    lstMonths.Items.Add("January")
    lstMonths.Items.Add("February")
    ...

    or, if filling from an array
    lstMonths.Items.Clear
    for I as integer = 0 to strMonths.GetUpperBound(0)
    lstMonths.Items.Add(strMonths(I))
    next I

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Array formula [ 12 Answers ]

I have a lookup table and I need a formula that looks at (example) h14 then i14 then looks up the table and returns the value associated with that row. Here is part of my formula, but its lacking something. =IF(h14<0.01," ",LOOKUP(h14,$A$368:$A$711,$G$368:$G$711)) Can anyone help, please....

Array controller [ 1 Answers ]

Have 4 drives in array. Three show as 1 logical; one shows as unallocated. How do I extend the unallocated to the logical.

An array [ 1 Answers ]

How many ratings do you wish to enter? 10 Rating #1: 9 Rating #2: 5 Rating #3: 9 Rating #4: 2 Rating #5: 11 Invalid entry, score must be in range of 1 and 10; try again. Rating #5: -1 Invalid entry, score must be in range of 1 and 10; try again. Rating #5: 8

Ordered List: Display letters instead of numbers [ 3 Answers ]

How can I use lower case letters, instead of numbers, in an ordered list? When I use this code for my ordered list it displays numbers: <ol> <li>first thing on the list</li> <li>second thing on the list </li> </ol> Thanks!


View more questions Search