Results 1 to 4 of 4

Thread: [RESOLVED] how do i preform reverse For loop ??

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    55

    Resolved [RESOLVED] how do i preform reverse For loop ??

    i'm sure its very simple, but i couldn't find how to do it

    my normal use of For Loop

    For x= 1 To 100
    bla bla
    Next

    how do i "count down" like this
    For X = 100 To 1

    ?

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: how do i preform reverse For loop ??

    For X = 100 To 1 Step -1
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  3. #3
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: how do i preform reverse For loop ??

    And if you don't know the exact code for it (step -1 would be the necessary addition) then just use basic arithmetic.

    Code:
    For x = 1 to 100
    Dim y as Integer = 100 - x
    Next
    But yes it is worth using the code for, much shorter and easier.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    55

    Re: how do i preform reverse For loop ??

    great, Step -1, silly me....

    and yes i knew the arithmetic 100-x , but i got Loops within Loops and it started getting confusing, it was obviuse that should be the simplest way to "reverse" it.

    thank you both,
    resolved

Posting Permissions

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



Click Here to Expand Forum to Full Width