title: Number Guessing game windows forms
body: <p>I'm doing a number guessing game in C#, the code is supposed to count players guesses and then add the number to a textbox. </p>
  
  <p>I don't really know how to implement it in my code though.</p>
  
  <p>I just need help with the textbox part of the code. </p>
  
  <p>The guesses are supposed to appear in <code>tbxMinaResultat</code></p>
  
  <pre><code>public partial class Form1 : Form    
  {
      Random rnd = new Random();
      int datornsTal;
      int guesses;
      int max;
      public Form1()
      {
  
  
          InitializeComponent();
          lbxStörstaTalet.Items.Add(10);
          lbxStörstaTalet.Items.Add(20);
  
  
      }
  
      private void BtnSpelaIgen_Click(object sender, EventArgs e)
      {
          gbxSpeldata.Enabled = true;
          gbxSpelet.Enabled = false;
      }
  
      private void LbxStörstaTalet_SelectedIndexChanged(object sender, EventArgs e)
      {
  
      }
  
      private void TbxMinaResultat_TextChanged(object sender, EventArgs e)
      {
          int guesses;
          tbxMinaResultat.Text = ToString(guesses);
  
      }
  
      private void Form1_Load(object sender, EventArgs e)
      {
  
      }
  
  
      private void BtnStartaSpelet_Click(object sender, EventArgs e)
      {
          int max = int.Parse(lbxStörstaTalet.SelectedItem.ToString());
          datornsTal = rnd.Next(0, max);
  
          gbxSpeldata.Enabled = false;
          gbxSpelet.Enabled = true;
          guesses = 0;
      }
  
      private void BtnGissa_Click(object sender, EventArgs e)
      {
          int guess = int.Parse(tbxGissa.Text);
  
          if (guess &gt; datornsTal)
          {
              lblResultat.Text = "Gissa lägre";
              guesses++;
          }
  
          else if (guess &lt; datornsTal)
          {
              lblResultat.Text = "Gissa Högre!";
              guesses++;
          }
  
          else if (guess == datornsTal)
          {
              lblResultat.Text = "Bra jobbat!";
              guesses++;
          } 
      }
  }
  </code></pre>