...

View Full Version : VB.net, add char every line using for, next loop



pita0017
02-15-2005, 11:14 PM
hi everyone, if someone could help me out with this id be grateful.....

im trying to make an additional x appear every line using a for next loop...like below:

x
xx
xxx
xxxx
xxxxx
xxxxxx
xxxxxxx
xxxxxxxx
xxxxxxxxx
xxxxxxxxxx

im trying to print that to a label.....heres my code so far:


Dim i As Integer

For i = 1 To 10
Label1.Text = "x" * i & vbCrLf
Next i


i know i cant multiply "x" times i, thats really what i want to know......thanks to anyone that can help me out....

liorean
02-15-2005, 11:22 PM
Typical school assignment - we won't help you cheat by giving you the code, the purpose of such assignments are for you to learn, not to just copy code written by somebody else.

pita0017
02-15-2005, 11:27 PM
ok, i understand what your saying, but im not asking for the code, ive been at this for hours, ive googled it, and my book is no help either....just maybe someone could explain what im doing wrong, without giving me the actual code....

Brandoe85
02-15-2005, 11:39 PM
Take out the "x" * i, as thats obvious. Look into +=.

pita0017
02-15-2005, 11:40 PM
Take out the "x" * i, as thats obvious. You're going to have 2 loops(or I would), and I would look into +=.

ok i will mess with that some, thanks.

pita0017
02-16-2005, 12:48 AM
ok i figured out, thanks to that info that brandoe85 gave me.....heres the code incase you dont believe me:



Dim i As Integer, StrOutput As String
Dim j As Integer

For j = 1 To 10
For i = 1 To 10
StrOutput += "x"
Label1.Text += StrOutput & vbCrLf
Next i
Next j


so to brandoe85, thanks for the help, u saved me from failing this assignment, and to liorean, thanks for being cynical instead of helpful....

Brandoe85
02-16-2005, 06:28 AM
Hmm...I edited my post about 2 loops, as i'm reading it again...I don't know why I said 2 loops(i know im retarded :0). It's really just a matter of 1 loop. And if you play around with your code i'm sure your going to realize it to :D

pita0017
02-16-2005, 09:34 PM
yea, i modified it quite a bit, that causes it to loop forever, i got it now, it just does the loop 10 times now...thanks again bro.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum