private void StartGame_Click(object sender, EventArgs e) { ComputerResponse.Text = ""; StartGame.Enabled = false; InputGuess.Show(); label1.Show(); UserInput.Show(); ComputersGuess = rd.Next(0, 11); }
private void InputGuess_Click(object sender, EventArgs e) { // check that the input from text box is a number int Result; // if input is a number if (int.TryParse(UserInput.Text, out Result)) { if (Convert.ToInt32(UserInput.Text) > ComputersGuess) { ComputerResponse.Text = "Too High!"; } else if (Convert.ToInt32(UserInput.Text) < ComputersGuess) { ComputerResponse.Text = ("Too Low!"); } else { ComputerResponse.Text = "Correct!"; // end game. StartGame.Enabled = true; InputGuess.Hide(); label1.Hide(); UserInput.Hide(); } } // if input isn't a number else { ComputerResponse.Text = "That Not a Number"; } }