title: Count the number of attempts and ask user to play again loops
body: <p>I am trying to make a new game for fun. The game is about guess a number. I used a Microsoft Visual Studio to make an application form. This program will give the user 10 attempts to get a correct guess. It will also tell that the number is too high or low. The program has a loop function to monitor the attempts. If the user guessed at 10 times, the program will stop. The problem is that the display shows the unchanged attempts. For example, the user guessed at five times, but the program's display still shows 10 attempts. It is same thing with stopping the program if the user used 10 attempts. The program should stop after 10 attempts but it is not working. I cannot find where the problem comes from. If anyone could help out with it would be greatly appreciated.</p>
  
  <pre><code>public class Main : Form
  
      int randomNumber;
      int count;
  
      private void Form1_Load(object sender, EventArgs e)
      {
          count = 10;
          randomNumber = generateRandomNumber();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {  
          int guess = 0;
          guess = Convert.ToInt32(textBox1.Text);
  
          for (int i = 1; i &lt;= count; i++)
          {
              label4.Text = "Guess Attempt: " + i;
  
              if (guess == randomNumber)
              {
                  label4.Text = "Your guess is correct! Game Won";
                  label2.Visible = false;
                  label3.Visible = false;
                  button1.Visible = false;
                  if (MessageBox.Show("Do you want to play again?", "Start a new game", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                  {
                      Application.Restart();
                  }
                  else
                  {
                      Application.Exit();
                  } 
                  break;
              }
              else 
                  if (guess &lt; randomNumber)
                  {
                      label2.Text = "Too low!";
  
                  }
                  else if (guess &gt; randomNumber)
                  {
                      label2.Text = "Too high!";
  
                  }
  
                  else if (i == count)
                  {
                      label2.Text = "Sorry, You missed it! Game Lost";
                      label3.Text = "The answer is " + randomNumber;
                      if (MessageBox.Show("Do you want to play again?", "Start a new game", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                  {
                      Application.Restart();
                  }
                  else
                  {
                      Application.Exit();
                  } 
                  }
          }
      }
  
      private int generateRandomNumber()
      {
          Random number = new Random();
          int randomNumber = number.Next(1, 100);
  
          return randomNumber;
      }
  </code></pre>