Hi all,
I want to be able to generate 6 random numbers from 1 to 20 and place each of those numbers into a label(of which there are 6).
But each number must be unique, i.e. no duplicates.
Any possible code for this???
Thanks
Mark
Printable View
Hi all,
I want to be able to generate 6 random numbers from 1 to 20 and place each of those numbers into a label(of which there are 6).
But each number must be unique, i.e. no duplicates.
Any possible code for this???
Thanks
Mark
The first technic would be to generated a random number, look for an array to see if it has already been generated, and continue like that.
But a better method would be to generate an array of 20 (with the number from 1 to 20) and shuffle the array (you know, swap elements) a X number of times, and after just take the number from indice 0 to 5, look at this example:
http://www.codeguru.com/forum/showth...&threadid=5650
JeffB - hope it helps