Results 1 to 3 of 3

Thread: Reverse For Loop

  1. #1

    Thread Starter
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Reverse For Loop

    In my game I am going through a list box of numbers and removing those entries in another list box. So if listA has 1,5,6,8,20 it would remove the entries in the spots 1,5,6,8,20 in listB.

    Since when you remove item 1, it changes the location of 5-20 I want to go in reverse, from 20,8,6,5,1. This way none of the items actually change location. I am using a forLoop of

    VB Code:
    1. maxArray = frmGameScreen.lstRemove.ListCount - 1
    2.         ' This loops in revers so it does not affect where the items lie in the listbox
    3.         ' Example : removing item 20 does not effect where item 4 is
    4.         For forLoop = maxArray To 0
    5.             frmGameScreen.lstComputer.RemoveItem (frmGameScreen.lstRemove.List(forLoop))
    6.         Next forLoop

    I have done reverse loops (large to small) before but for some reason the entire forLoop is skipped.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  2. #2
    Hyperactive Member
    Join Date
    Jun 2004
    Posts
    468

    Re: Reverse For Loop

    "Step -1" is missing from the end of the For command.

  3. #3

    Thread Starter
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: Reverse For Loop

    Now how did I miss that? I swear I had it. Thanks. I was looking at the code for so long I am starting to see things that arent there.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

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