1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VB.NET non-repeating random number

Discussion in 'Software Development' started by Ciberblade, Sep 4, 2004.

Thread Status:
Not open for further replies.
  1. Ciberblade

    Ciberblade Retired Moderator Thread Starter

    Joined:
    Sep 22, 2003
    Messages:
    16,279
    I am trying to write a method that I can pass in two values (low number, high number) and will return a non-repeating random number within this range, one number at a time (possibly button click, not sure yet - I'll tackle that later). Once all available numbers are used, I want it to return a -1. I cannot move on until I get this tested functionally. I am trying to make use of a binary array to keep track of used numbers by index. Here is what I have so far:

    Any ideas?
     

    Attached Files:

  2. Chicon

    Chicon

    Joined:
    Jul 29, 2004
    Messages:
    6,650
  3. Ciberblade

    Ciberblade Retired Moderator Thread Starter

    Joined:
    Sep 22, 2003
    Messages:
    16,279
    Chicon ~ thanks for the reference (y)

    I ended up setting a counter equal to the size of my array, then incrementing that counter each time through the loop - using that to index my boolean. It is satisfying :)
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/270269

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice