There is a series of 15 questions that are submitted to the screen according to the following conditions:
if (i % 2 == 0){} if (i % 3 == 0){} if (i % 5 == 0){} How to exclude an overlay of questions, namely to exclude the fulfillment of conditions with common divisors, for example, the numbers 6,10,12,15.
Code to modify else if:
if (i % 3 == 0 && i != 0) { if (i % 2 == 0) { } else if (j < dataGridView2.Rows.Count - 1) { } } Fragment of the issue code:
if(i==0 || i==1 || i % 2 == 0) { if (f < dataGridView1.Rows.Count - 1) { // QuestionTime = DateTime.Now; textBox1.Visible = false; radioButton1.Visible = true; radioButton2.Visible = true; radioButton3.Visible = true; groupBox1.Visible = false; this.Text = Transfer; label1.Text = dataGridView1.Rows[f].Cells[2].Value.ToString(); QuestionVariantString = dataGridView1.Rows[f].Cells[3].Value.ToString(); QuestionSplit = QuestionVariantString.Split(';'); QuestionTrueChoice = dataGridView1.Rows[f].Cells[4].Value.ToString(); radioButton1.Text = QuestionSplit[0]; radioButton2.Text = QuestionSplit[1]; radioButton3.Text = QuestionSplit[2]; button1.Enabled = false; f++; } } else if (i % 3 == 0 && i != 0) { if (j < dataGridView2.Rows.Count - 1) { // QuestionTime = DateTime.Now; textBox1.Text = ""; radioButton1.Visible = false; radioButton2.Visible = false; radioButton3.Visible = false; groupBox1.Visible = false; textBox1.Visible = true; label1.Text = dataGridView2.Rows[j].Cells[2].Value.ToString(); QuestionTrueChoice = dataGridView2.Rows[j].Cells[3].Value.ToString(); QuestionSense = textBox1.Text; j++; } } else if (i % 5 == 0 && i != 0) { if (g < dataGridView3.Rows.Count - 1) { // QuestionTime = DateTime.Now; radioButton1.Visible = false; radioButton2.Visible = false; radioButton3.Visible = false; groupBox1.Visible = true; label1.Text = dataGridView3.Rows[g].Cells[2].Value.ToString(); QuestionVariantString = dataGridView3.Rows[g].Cells[3].Value.ToString(); QuestionSplit = QuestionVariantString.Split(';'); QuestionTrueChoice = dataGridView3.Rows[g].Cells[4].Value.ToString(); checkBox1.Text = QuestionSplit[0]; checkBox2.Text = QuestionSplit[1]; checkBox3.Text = QuestionSplit[2]; checkBox4.Text = QuestionSplit[3]; g++; } } When I = 6, the conditions, as I understand it, are fulfilled twice and, as a result, the question is duplicated.
else if, most likely it was not so recorded - yolosora