VB.NET non-repeating random number

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Ciberblade

Thread Starter
Retired Moderator
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?
 

Attachments

Ciberblade

Thread Starter
Retired Moderator
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 :)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top