SHARE
TWEET

Untitled

a guest Oct 18th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.         private void BtnGuessNhor_Click(object sender, EventArgs e)
  3.         {
  4.             int minNhor = Convert.ToInt32(txbMinNumberNhor.Text);
  5.             int maxNhor = Convert.ToInt32(txbMaxNumberNhor.Text);
  6.  
  7.             try
  8.             {
  9.                 lblAnswerPrevGuessNhor.Text = guessNhor.ToString();
  10.  
  11.                 answerNhor = Convert.ToInt32(lblAnsMysNumNhor.Text);
  12.                 guessNhor = Convert.ToInt32(txbMyGuessNhor.Text);
  13.             }
  14.             catch (Exception)
  15.             {
  16.                 MessageBox.Show("Please fill in numbers");
  17.             }
  18.  
  19.             if (guessNhor == answerNhor)
  20.             {
  21.                 //play audio
  22.                 mciSendString("open \"" + Application.StartupPath
  23.                       + "\\..\\..\\Music\\"
  24.                       + "zapsplat_multimedia_game_sound_mallet_positive_advance_003_40873.mp3\" "
  25.                       + "type mpegvideo alias MediaFile",
  26.                null, 0, IntPtr.Zero);
  27.                 mciSendString("play MediaFile", null, 0, IntPtr.Zero);
  28.  
  29.                 attemptsWinNhor++;
  30.                 DialogResult = MessageBox.Show("You won! \nwins/losses: " + attemptsWinNhor + "/" + attemptsLoseNhor + "\nPlay again? ", "Winner", MessageBoxButtons.YesNo);
  31.  
  32.             }
  33.             else if (guessNhor < answerNhor)
  34.             {
  35.                 differenceNhor = answerNhor - guessNhor;
  36.             }
  37.             else if (guessNhor > answerNhor)
  38.             {
  39.                 differenceNhor = guessNhor - answerNhor;
  40.             }
  41.  
  42.             trbNhor.Maximum = maxNhor;
  43.             trbNhor.Value = (maxNhor - differenceNhor);
  44.  
  45.             if (guessNhor < minNhor || guessNhor > maxNhor)
  46.             {
  47.                 MessageBox.Show("Guessed number not between the min and max number");
  48.             }
  49.             pgbGuessesNhor.Value--;
  50.             lblAnswerLeftNhor.Text = pgbGuessesNhor.Value.ToString();
  51.             if (pgbGuessesNhor.Value == 0)
  52.             {
  53.                 //play audio
  54.                 mciSendString("open \"" + Application.StartupPath
  55.                       + "\\..\\..\\Music\\"
  56.                       + "zapsplat_multimedia_game_sound_mallet_fall_descend_002_40840.mp3\" "
  57.                       + "type mpegvideo alias MediaFile",
  58.                null, 0, IntPtr.Zero);
  59.                 mciSendString("play MediaFile", null, 0, IntPtr.Zero);
  60.  
  61.                 attemptsLoseNhor++;
  62.                 DialogResult = MessageBox.Show("Game over!\nthe answer was " + lblAnsMysNumNhor.Text + "\nwins/losses: " + attemptsWinNhor + "/" + attemptsLoseNhor + "\nPlay Again?", "Loser", MessageBoxButtons.YesNo);
  63.             }
  64.             lblAnsDiffNhor.Text = differenceNhor.ToString();
  65.  
  66.             if (DialogResult == DialogResult.Yes)
  67.             {
  68.                 RestartNhor();
  69.             }
  70.             else if (DialogResult == DialogResult.No)
  71.             {
  72.                 this.Close();
  73.             }
  74.  
  75.  
  76.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top