Question trouble with list boxes. ( homework help )

cozmo

Member
Joined
Sep 28, 2012
Messages
7
Programming Experience
3-5
Hello all. I'm having difficulty displaying text using a FOR-NEXT loop and displaying its results to a list box. At this point, I don't know if there's something I'm not doing to the ListBox1's property to make it display a list. I've followed many examples but all present results to a console and I got that to work, but not a listbox.

It seems so simple...

At what point to you write to each line in the list? (or is this not how they work)


VB.NET:
For x As Integer = 1 to 100[INDENT]{do something}[/INDENT]
next

the result i'm trying to get a simple list in the box:
1
2
3
4
5


Thanks!

Coz
 
Perhaps your search terms were not ambiguous enough.

I googled : "vb.net how to add items to listbox" and had my answer from the meta-text without having to click into any of the links.

Try that search phrase yourself and see if it helps. I'm not sure what the forum etiquette is on homework problems so I wont spell out the answer for you. I will tell you however that you are right, it is simple. If you break your problem down into its pieces then it will be easier. First (piece 1), you need to add items to a listbox.. Second (piece 2), you need to utilize a for/next loop to carry out piece 1.

So your steps should be first to learn how to add 1 item to a list box, second, how to use a for next loop, and then third, put them both together.

Hope this helps
 
Thank you 22, it does help because I didn't realize I was "adding" items, I keep trying to find a way to make a listbox mimic the sequential display I'm getting from a console. :)

Also, a good note on forum etiquette as I certainly don't want anyone doing my homework. Ok, I'll keep plugging away. Thanks again.

Sent from my EVO using Tapatalk 2
 
I will tell you however that you are right, it is simple.

Yep! (I feel dumb) This is all I was trying to do. Obviously, I'm not going to see that with output to a console. As I stated, I was thinking of "listing" as I've done in other languages. It just never occurred that I needed to "add". Anyway, problem solved--now the logic...

VB.NET:
Dim int1 As Integer


        For int1 = 1 To 10
            ListBox1.Items.Add(int1)
            {more stuff to code}
            {Exit when condition is met}
        Next int1
 
Back
Top