Persentage [modified]
-
I am trying to make the guess the number game, but now I am confised as I don't get an aswer at all at the end, I don't know where the problem is, I run it and it goes tru the code, at the end it does not give a respose at all. I am putting persetage in for hot,warm,warem eg. I have put in code for a aswer
Private Sub btnCheckGuess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckGuess.Click Dim intPlayerGuess As Integer 'Declare variable to store guess Static intNoOfGuesses As Integer 'Declare variable to keep track 'of the number of guesses made If txtInput.Text.Length > 0 Then 'Make sure player typed something If IsNumeric(txtInput.Text) = True Then 'Ensure input is numeric 'Convert String input to Integer data type intPlayerGuess = Int32.Parse(txtInput.Text) btnCheckGuess.Enabled = True 'Enable Check Guess button 'See if player’s guess is correct If intPlayerGuess = intRandomNumber Then txtInput.Text = "" 'Clear the TextBox control intNoOfGuesses += 1 'Increment variable by one 'See if player enabled verbose messaging If chkVerbose.Checked = True Then txtOutput.Text = "Congratulations!" & ControlChars.CrLf & ControlChars.CrLf & "You have won the Guess a Number Game. " & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses made = " & intNoOfGuesses Else txtOutput.Text = "Congratulations! You Win." End If intNoOfGuesses = 0 'Reset variable to zero txtInput.Enabled = False 'Disable TextBox control 'Update the display of the total number of games won txtGamesWon.Text = txtGamesWon.Text + 1 'Disable the Button labeled Check Guess btnCheckGuess.Enabled = False 'Enable the Button labeled New Game btnNewGame.Enabled = True 'Enable all Radio buttons rbnControl10.Enabled = True rbnControl100.Enabled = True rbnControl1000.Enabled = True 'Enable the two reset buttons btnDefaults.Enabled = True btnReset.Enabled = True 'Post statusbar message stbControl.Text = "Game Ready!" End If 'More If (intPlayerGuess) * 100 / intRandomNumber < intRandomNumber Then answer = answer End If 'Less If intPlayerGuess > intRandomNumber * 100 / intPlayerGuess Then answer = answer End If 'Getting Hot If answer > 96 Then txtInput.Text = "" intNoOfGuesses += 1 If chkVerbose.Checked = True Then txtOutput.Text = "You are Hot." & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses taken so far = " & intNoOfGuesses Else txtOutput.Text = "H
-
I am trying to make the guess the number game, but now I am confised as I don't get an aswer at all at the end, I don't know where the problem is, I run it and it goes tru the code, at the end it does not give a respose at all. I am putting persetage in for hot,warm,warem eg. I have put in code for a aswer
Private Sub btnCheckGuess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckGuess.Click Dim intPlayerGuess As Integer 'Declare variable to store guess Static intNoOfGuesses As Integer 'Declare variable to keep track 'of the number of guesses made If txtInput.Text.Length > 0 Then 'Make sure player typed something If IsNumeric(txtInput.Text) = True Then 'Ensure input is numeric 'Convert String input to Integer data type intPlayerGuess = Int32.Parse(txtInput.Text) btnCheckGuess.Enabled = True 'Enable Check Guess button 'See if player’s guess is correct If intPlayerGuess = intRandomNumber Then txtInput.Text = "" 'Clear the TextBox control intNoOfGuesses += 1 'Increment variable by one 'See if player enabled verbose messaging If chkVerbose.Checked = True Then txtOutput.Text = "Congratulations!" & ControlChars.CrLf & ControlChars.CrLf & "You have won the Guess a Number Game. " & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses made = " & intNoOfGuesses Else txtOutput.Text = "Congratulations! You Win." End If intNoOfGuesses = 0 'Reset variable to zero txtInput.Enabled = False 'Disable TextBox control 'Update the display of the total number of games won txtGamesWon.Text = txtGamesWon.Text + 1 'Disable the Button labeled Check Guess btnCheckGuess.Enabled = False 'Enable the Button labeled New Game btnNewGame.Enabled = True 'Enable all Radio buttons rbnControl10.Enabled = True rbnControl100.Enabled = True rbnControl1000.Enabled = True 'Enable the two reset buttons btnDefaults.Enabled = True btnReset.Enabled = True 'Post statusbar message stbControl.Text = "Game Ready!" End If 'More If (intPlayerGuess) * 100 / intRandomNumber < intRandomNumber Then answer = answer End If 'Less If intPlayerGuess > intRandomNumber * 100 / intPlayerGuess Then answer = answer End If 'Getting Hot If answer > 96 Then txtInput.Text = "" intNoOfGuesses += 1 If chkVerbose.Checked = True Then txtOutput.Text = "You are Hot." & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses taken so far = " & intNoOfGuesses Else txtOutput.Text = "H