private void BarcodeButton_Click(object sender, EventArgs e) { try { int smallestNumber = 100000; int biggestNumber = 5000000; //Determine the amount of random numbers int amountOfRandomNumbers = 10; //Create a list of numbers from which the routine //shall choose the result numbers var possibleNumbers = new List<int>(); for (int i = smallestNumber; i <= biggestNumber; i++) possibleNumbers.Add(i); var result = new List<int>(); //Initialize a random number generator Random rand = new Random(); //For-loop which picks each round a unique random number for (int i = 0; i < amountOfRandomNumbers; i++) { //Generate random number int randomNumber = rand.Next(1, possibleNumbers.Count) - 1; barcodeTextEdit.Text = randomNumber.ToString(); //Remove the chosen result number from possible numbers list possibleNumbers.RemoveAt(randomNumber); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)