private void button1_Click(object sender, EventArgs e) { // Generate a random number RandomNumber = random.Next(1, 7); // This section of code will be used to select a new random question. It will ensure that the user does not recieve the same question twice. if (RandomNumber == 1 && Globalvariables.CompletedQuestionsB[0] == false) { frmQuestion1b Question1b = new frmQuestion1b(); this.Close(); Question1b.Show(); } else if (RandomNumber == 2 && Globalvariables.CompletedQuestionsB[1] == false) { frmQuestion2b Question2b = new frmQuestion2b(); this.Close(); Question2b.Show(); } else if (RandomNumber == 3 && Globalvariables.CompletedQuestionsB[2] == false) { frmQuestion3b Question3b = new frmQuestion3b(); this.Close(); Question3b.Show(); } else if (RandomNumber == 4 && Globalvariables.CompletedQuestionsB[3] == false) { frmQuestion4b Question4b = new frmQuestion4b(); this.Close(); Question4b.Show(); } else if (RandomNumber == 5 && Globalvariables.CompletedQuestionsB[4] == false) { frmQuestion5b Question5b = new frmQuestion5b(); this.Close(); Question5b.Show(); } else if (RandomNumber == 6 && Globalvariables.CompletedQuestionsB[5] == false) { frmQuestion6b Question6b = new frmQuestion6b(); this.Close(); Question6b.Show(); } else if (RandomNumber == 7 && Globalvariables.CompletedQuestionsB[6] == false) { frmQuestion7b Question7b = new frmQuestion7b(); this.Close(); Question7b.Show(); } }
private void timer1_Tick(object sender, EventArgs e) { if (Globalvariables.form == 5) { frmEndb Finish = new frmEndb(); // Opens end screen this.Hide(); Finish.Show(); // Opens end screen NextQuestion.Stop(); } else { // This section of code will be used to select a new random question. It will ensure that the user does not recieve the same question twice. if (RandomNumber == 1 && Globalvariables.CompletedQuestionsB[0] == false) { frmQuestion1b Question1b = new frmQuestion1b(); this.Close(); Question1b.Show(); NextQuestion.Stop(); } else if (RandomNumber == 2 && Globalvariables.CompletedQuestionsB[1] == false) { frmQuestion2b Question2b = new frmQuestion2b(); this.Close(); Question2b.Show(); NextQuestion.Stop(); } else if (RandomNumber == 3 && Globalvariables.CompletedQuestionsB[2] == false) { frmQuestion3b Question3b = new frmQuestion3b(); this.Close(); Question3b.Show(); NextQuestion.Stop(); } else if (RandomNumber == 4 && Globalvariables.CompletedQuestionsB[3] == false) { frmQuestion4b Question4b = new frmQuestion4b(); this.Close(); Question4b.Show(); NextQuestion.Stop(); } else if (RandomNumber == 5 && Globalvariables.CompletedQuestionsB[4] == false) { frmQuestion5b Question5b = new frmQuestion5b(); this.Close(); Question5b.Show(); NextQuestion.Stop(); } else if (RandomNumber == 6 && Globalvariables.CompletedQuestionsB[5] == false) { frmQuestion6b Question6b = new frmQuestion6b(); this.Close(); Question6b.Show(); NextQuestion.Stop(); } else if (RandomNumber == 7 && Globalvariables.CompletedQuestionsB[6] == false) { frmQuestion7b Question7b = new frmQuestion7b(); this.Close(); Question7b.Show(); NextQuestion.Stop(); } else { RandomNumber = random.Next(1, 7); } } }