Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jul 2004
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts

    VB.net, add char every line using for, next loop

    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:
    Code:
    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....

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    New Coder
    Join Date
    Jul 2004
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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....

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Take out the "x" * i, as thats obvious. Look into +=.
    Last edited by Brandoe85; 02-16-2005 at 05:25 AM. Reason: I'm retarded....:0

  • #5
    New Coder
    Join Date
    Jul 2004
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Brandoe85
    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.

  • #6
    New Coder
    Join Date
    Jul 2004
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts
    ok i figured out, thanks to that info that brandoe85 gave me.....heres the code incase you dont believe me:

    Code:
    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....

  • #7
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    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

  • #8
    New Coder
    Join Date
    Jul 2004
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •