Hi Guys
i am working on quiz test,but i have stuck on next flag question button ,my code is not working at all.Can any body assist me please

private void btnNextFlagQuestion_Click(object sender, EventArgs e)
        { 
          i=0;
          for(i = 0; i<10;i++) 

              if(i<10) 
           MessageBox.Show ("messagebox you have finished" );
            } 
            if (User_Answer[] != Correct_Answer[])
                {
                    textBox1.Text = (i + 1) + ". " + Questions[i];
                    radioButton1.Text = option1[i];
                    radioButton2.Text = option2[i];
                    radioButton3.Text = option3[i];
                    radioButton4.Text = option4[i];
                    btnFinish.Enabled = true;
                    i++;
    }

        if ((radioButton1.Checked) || (radioButton2.Checked) || (radioButton3.Checked) || (radioButton4.Checked) || (chkFlagQuestion.Checked))




        }
    }
}
}
}

If you could put you option array declaration and curly brackets of the for loop to know where it ends and the User_Answer and Correct_Answer arrays and it would be good to put the code for the last if statement, if checked then what.

Either a lot of your code is missing, or you're mis-bracketing. Essentially, in this code, you're closing your method on line 8.

None of this code should compile.

I have written my return Flag Question code and next flag question No errors .But when i ran it doesnt work.KINDLY help.

private void btnReturnFlagQuestion_Click(object sender, EventArgs e)
        {



            //Initialize  counter and set to 0
            i = 0;

            //If the user answer is not equal to correct answer
            if (User_Answer[i] != Correct_Answer[i])
            {
                // Populate the window with the first failed question if the wrong answer has been selected.
                textBox1.Text = (i + 1) + "." + Questions[i];//To print first question of array
                radioButton1.Text = option1[i];//print first option of array
                radioButton2.Text = option2[i];//print first option of array
                radioButton3.Text = option3[i];//print first option of array
                radioButton4.Text = option4[i];//print first option of array

                // Option button to clearing
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                radioButton4.Checked = false;
                btnRepeatFailedQuestion.Enabled = false;
            }
            //else if the first question is answered correctly
            else
            {
                do
                {
                    i++; // Move to the next question
                } while (User_Answer[i] == Correct_Answer[i]); //While the user answer is equal to the correct answer the move to the next question

                // if user answer is not equal to the correct answer then populate the window failed question
                if (User_Answer[i] != Correct_Answer[i])
                {
                    textBox1.Text = (i + 1) + ". " + Questions[i];//To print first question of array
                    radioButton1.Text = option1[i];//print first option of array
                    radioButton2.Text = option2[i];//print first option of array
                    radioButton3.Text = option3[i];//print first option of array
                    radioButton4.Text = option4[i];//print first option of array
                    btnFinish.Enabled = true;
                    i++;

                }
                else
                {
                    do
                    {
                        i++;//Move to a next question
                    } while (User_Answer[i] == Correct_Answer[i]); //while user answer is equal to a correct answer then move to the next question

                    // If User answer is no equal to the correct answer the populate the window with failed question


                    textBox1.Text = (i + 1) + "." + Questions[i];//To print first question of array
                    radioButton1.Text = option1[i];//print first option of array
                    radioButton2.Text = option2[i];//print first option of array
                    radioButton3.Text = option3[i];//print first option of array
                    radioButton4.Text = option4[i];//print first option of array
                    btnFinish.Enabled = true;
                    i++;
                    btnReviewFlagQuestion.Enabled = true;
                }

            }

Guys help me pls

 private void btnNextFlagQuestion_Click(object sender, EventArgs e)
        {
            if (i < 10) // If there are further questions
            {
                if (User_Answer[i] != Correct_Answer[i])
                textBox1.Text = (i + 1) + "." + Questions[i];//To print first question of array
                radioButton1.Text = option1[i];//print first option of array
                radioButton2.Text = option2[i];//print first option of array
                radioButton3.Text = option3[i];//print first option of array
                radioButton4.Text = option4[i];//print first option of array
                i++;


            }
            if ((radioButton1.Checked) || (radioButton2.Checked) || (radioButton3.Checked) || (radioButton4.Checked) || (chkFlagQuestion.Checked))
            {
                if (i < 10)
                {
                    if (radioButton1.Checked)
                    {
                        User_Answer[i] = 1;
                    }
                    if (radioButton2.Checked)
                    {
                        User_Answer[i] = 2;
                    }
                    if (radioButton3.Checked)
                    {
                        User_Answer[i] = 3;
                    }
                    if (radioButton4.Checked)
                    {
                        User_Answer[i] = 4;
                    }
                    else if (chkFlagQuestion.Checked)
                    {
                        User_Answer[i] = 0;
                    }

                    while (User_Answer[i] == Correct_Answer[i])


                        textBox1.Text = (i + 1) + "." + Questions[i];
                    radioButton1.Text = option1[i];
                    radioButton2.Text = option2[i];
                    radioButton3.Text = option3[i];
                    radioButton4.Text = option4[i];
                    i++;
                    {

                        if (i == 9)
                        {
                            btnFinish.Enabled = true;
                            MessageBox.Show("Bernard");
                        }

                    }
                }
            }

First, please be patient. It's obvious we're in different time zones, so you're not going to get an immediate response.

Second, tell us what you're expecting to happen and also tell us what is happening.

Unfortunately, pasting code and saying "it doesn't work", especially if the code is valid, isn't enough for us to go on in most cases...

Edited 3 Years Ago by Ketsuekiame: typos (and again! should probably learn to use the spell check/preview)

This article has been dead for over six months. Start a new discussion instead.