Help here...allow the files display randomly
-
Hi everyone:), I have a problem here, my program can automatic display 12 files when the button is click.I use timer to let the 12 files to display orderly. But my question is " How to allow the 12 files to display randomly everytime when i click the button" :confused: :laugh:Thank for helpin
-
Hi everyone:), I have a problem here, my program can automatic display 12 files when the button is click.I use timer to let the 12 files to display orderly. But my question is " How to allow the 12 files to display randomly everytime when i click the button" :confused: :laugh:Thank for helpin
could you explain more ??
When you get mad...THINK twice that the only advice Tamimi - Code
-
could you explain more ??
When you get mad...THINK twice that the only advice Tamimi - Code
Yes... The 12 files is the 12 waveform to be display one by one automatically when i click the button.My program can only allow the 12 waveform to display in order when i run the program( everytime when i run the program, the 12 waveform will display from 1 to 12). Therefore my problem is " how to allow the 12 waveform to display randomly." for example when i run the program, the third waveform will run first. And when i run the program the second time, the tenth waveform will run first. Hope u understand..;) thank..
-
Yes... The 12 files is the 12 waveform to be display one by one automatically when i click the button.My program can only allow the 12 waveform to display in order when i run the program( everytime when i run the program, the 12 waveform will display from 1 to 12). Therefore my problem is " how to allow the 12 waveform to display randomly." for example when i run the program, the third waveform will run first. And when i run the program the second time, the tenth waveform will run first. Hope u understand..;) thank..
this is what I think you need:
static void Main(string[] args) { RunRandomly(12); } static void RunRandomly(int amount) { ArrayList alreadyused = new ArrayList(); Random rnd = new Random(); while (amount > 0) { int rndint = Convert.ToInt32(rnd.Next(12)); if (!alreadyused.Contains(rndint)) { Run(rndint); amount--; alreadyused.Add(rndint); } } } static void Run(int number) { // do whatever you need to do, number will be a random number between 0 and 11 Console.WriteLine(number); }
if it doesn't make sense, then neither did your question I'm afraid ;)
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
-
this is what I think you need:
static void Main(string[] args) { RunRandomly(12); } static void RunRandomly(int amount) { ArrayList alreadyused = new ArrayList(); Random rnd = new Random(); while (amount > 0) { int rndint = Convert.ToInt32(rnd.Next(12)); if (!alreadyused.Contains(rndint)) { Run(rndint); amount--; alreadyused.Add(rndint); } } } static void Run(int number) { // do whatever you need to do, number will be a random number between 0 and 11 Console.WriteLine(number); }
if it doesn't make sense, then neither did your question I'm afraid ;)
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
joon vh. wrote:
int rndint = Convert.ToInt32(rnd.Next(12));
No need to call
Convert.ToInt32
here sinceRandom.Next
returns an integer.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
joon vh. wrote:
int rndint = Convert.ToInt32(rnd.Next(12));
No need to call
Convert.ToInt32
here sinceRandom.Next
returns an integer.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook