Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Persentage [modified]

Persentage [modified]

Scheduled Pinned Locked Moved Visual Basic
cssgame-devhelpannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hendrikbez
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • H hendrikbez

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Bluärgh! Please use the pre tag when posting larger blocks of code. It's virtually unreadable in that form.

      --- b { font-weight: normal; }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups