title: Windows form application - C# Random numer guessing game
body: <p>I need a little help with a Random Number Guessing Game in visual studio.  I got the brunt of the code down but I am having troubles with the Random number generator and getting the random number to port into the click events.  As always, I don't really need code but some guidance and/or explanations as to what I am doing wrong and if there is a more effecient way to do things in the beginner phases of learning.  Below is my code, the comments are the parts where I am having troubles.  Thanks for any help as the help I've recieved to date as been phenominal.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace LAB6B
  {
      public partial class game : Form
      {
          public game()
          {
              InitializeComponent();
  
              //Generate Random number between 1 and 100
           //Not sure if there is a better way?
              Random rand1 = new Random();
              int num1 = rand1.Next(1,50);
              int num2 = rand1.Next(1,50);
              int answer = num1 + num2;
  
          }
  
          private void evaluate_Click(object sender, EventArgs e)
          {
              int count = 0;
              int choice = Convert.ToInt32(guess);
  
  
              if (guess.Text != string.Empty)
              {
                  // set counter to keep track of how many tries
                  // should this be done by a loop or will it count without a loop?
                  count++;
  
                  //compare user input against random number
            //Can’t import the random number for comparision
                  if (choice &lt; answer)
                  {
                      Evaluate.Visible = false;
                      lblMessage.Visible = true;
                      lblMessage.Text = "Too Low!";
                      Clear.Visible = true;
                      BackColor = Color.LightSeaGreen;
                  }
                  else if (choice &gt; answer)
                  {
                      Evaluate.Visible = false;
                      lblMessage.Visible = true;
                      lblMessage.Text = "Too High!";
                      Clear.Visible = true;
                      BackColor = Color.SlateBlue;
                  }
                  else
                  {
                      //Display correct message along with how many times it took to get it
                      MessageBox.Show(" Eso es CORRECTO! It took you {0} tries. ", count);
                  }
              }
          }
  
          private void Clear_Click(object sender, EventArgs e)
          {
              guess.Text = "";
              Evaluate.Visible = true;
              lblMessage.Visible = false;
              Clear.Visible = false;
              BackColor = Color.PowderBlue;
          }
      }
  }
  </code></pre>