Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  Answer this Question    Ask about Visual Basic    Ask about another Subject  
 

vitaming
Oct 18, 2009, 07:28 AM
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
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