Results 1 to 4 of 4

Thread: Need help understanding how to flag a number in relation to arrays. PLEASE

Threaded View

  1. #3
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,500

    Re: Need help understanding how to flag a number in relation to arrays. PLEASE

    Quote Originally Posted by hablahblahblah View Post
    I am having trouble figuring out a way to mark a number as already in use so said number is not repeated. Any suggestions or know of any videos that can be helpful?
    Here is my program so far I highlighted where I am having trouble:
    Try this:

    Add an invisible, unsorted ListBox.

    'Add' to the ListBox all the numbers you wish to use. A straight 1 to however many will do. (Doesn't have to start at 1 of course)

    While the ListBox count is > 0
    Generate a random number between 0 and ListBox.items.Count -1.

    Use the number in that ListBox Index as the selected number.
    Remove that index from the ListBox.
    (the count will now be one less and the remaining higher numbers will have all moved down one)

    This way you can only pull out unused numbers, and you don't have to wait for your RNG to find an unused number, which can take quite a while when you're down to the last few remaining numbers especially.

    Poppa.


    Oh... I see that's more or less what Funky Dexter's suggested.

    Pop.
    Last edited by Poppa Mintin; May 7th, 2016 at 11:06 AM. Reason: Sorry FD.
    Along with the sunshine there has to be a little rain sometime.

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