• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Some VB.net homework help plz.

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

EclipseJP

Member
Joined
Nov 2, 2001
Location
In front of my Computer
I have to use a for next statement in one of the buttons. It has to count from 0 to 20 by ones. I have that down. Now I have to display that in a label. I mean have it show (0 1 2 .... 20) in the label. Here is what I tried.

For intCounter = 0 To 20
Debug.WriteLine(intCounter)
lblOutput.Text = intcounter
Next intcounter

Its nowhere in my book on how to do it. The teacher makes up the assignments himself. Now obviously that only shows 20. He showed us quickly last week. I should of taken better notes.
 
I believe it is something like the following:
lblOutput.Text = String.Concat(lablOutput.Text, intcounter)

You might need to do a ToString on the intcounter. I don't remember exactly.

Please mind my grammer. VB.Net isn't my native language, so to speak.
 
Looking at the MSDN reference for String.Concat it looks like the syntax should be more like:

lblOutput.Text = [String].Concat(lablOutput.Text, " ", intcounter)

Also, before you start the loop you should initialize the text to an empty string to get rid of what was already there. Something like this:

lblOutput.Text = ""
 
Perfect that worked!!!!!

For intCounter = 0 To 20
Debug.WriteLine(intCounter)
lblOutput.Text = String.Concat(lblOutput.Text, " ",intcounter)
Next intcounter


Thanks very much!!!
Now 2 more buttons to go.
Do while and do until.
 
Back