private void btnStart_Click(object sender, EventArgs e)
{
Random ran = new Random();
int[] randomNum = new int[6];
for (int j = 0; j < 6; j++)
{
randomNum[j] = ran.Next(imageNameArray.Length);
}
picOne.Image = Image.FromFile(imageNameArray[randomNum[0]]);
picTwo.Image = Image.FromFile(imageNameArray[randomNum[1]]);
picThree.Image = Image.FromFile(imageNameArray[randomNum[2]]);
picFour.Image = Image.FromFile(imageNameArray[randomNum[3]]);
picFive.Image = Image.FromFile(imageNameArray[randomNum[4]]);
picSix.Image = Image.FromFile(imageNameArray[randomNum[5]]);
}
basicly when I hit the start button this code will run, what it has to do is create a 6 new slots in an array and then fill them with random numbers wich will be used to select six images from a file. Sometimes it gets reapeted images and i dont want that, the way to do according to me is by going throw the random numbers array and see that they have no reapeted ones.
But i fail at that, if anyone could help me i would greatly apreciate it.
This post has been edited by poncho4all: 20 December 2009 - 03:58 PM

New Topic/Question
Reply




MultiQuote





|