Click here to Skip to main content
15,887,027 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionListView Pin
microuser_200010-Sep-06 23:42
microuser_200010-Sep-06 23:42 
AnswerRe: ListView Pin
mr_lasseter11-Sep-06 2:57
mr_lasseter11-Sep-06 2:57 
GeneralRe: ListView Pin
microuser_200011-Sep-06 20:10
microuser_200011-Sep-06 20:10 
AnswerRe: ListView Pin
Dave Kreskowiak11-Sep-06 5:46
mveDave Kreskowiak11-Sep-06 5:46 
GeneralRe: ListView Pin
microuser_200011-Sep-06 20:12
microuser_200011-Sep-06 20:12 
Questioncode to flowchart [modified] Pin
hirenkshah10-Sep-06 21:04
hirenkshah10-Sep-06 21:04 
AnswerRe: code to flowchart Pin
Kevin McFarlane10-Sep-06 23:15
Kevin McFarlane10-Sep-06 23:15 
QuestionPersentage [modified] Pin
hendrikbez10-Sep-06 20:53
hendrikbez10-Sep-06 20:53 
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<br />
<br />
Dim intPlayerGuess As Integer 'Declare variable to store guess<br />
<br />
Static intNoOfGuesses As Integer 'Declare variable to keep track<br />
<br />
'of the number of guesses made<br />
<br />
If txtInput.Text.Length > 0 Then 'Make sure player typed something<br />
<br />
If IsNumeric(txtInput.Text) = True Then 'Ensure input is numeric<br />
<br />
'Convert String input to Integer data type<br />
<br />
intPlayerGuess = Int32.Parse(txtInput.Text)<br />
<br />
btnCheckGuess.Enabled = True 'Enable Check Guess button<br />
<br />
'See if player’s guess is correct<br />
<br />
If intPlayerGuess = intRandomNumber Then<br />
<br />
txtInput.Text = "" 'Clear the TextBox control<br />
<br />
intNoOfGuesses += 1 'Increment variable by one<br />
<br />
'See if player enabled verbose messaging<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "Congratulations!" & ControlChars.CrLf & ControlChars.CrLf & "You have won the Guess a Number Game. " & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses made = " & intNoOfGuesses<br />
<br />
Else<br />
<br />
txtOutput.Text = "Congratulations! You Win."<br />
<br />
End If<br />
<br />
intNoOfGuesses = 0 'Reset variable to zero<br />
<br />
txtInput.Enabled = False 'Disable TextBox control<br />
<br />
'Update the display of the total number of games won<br />
<br />
txtGamesWon.Text = txtGamesWon.Text + 1<br />
<br />
'Disable the Button labeled Check Guess<br />
<br />
btnCheckGuess.Enabled = False<br />
<br />
'Enable the Button labeled New Game<br />
<br />
btnNewGame.Enabled = True<br />
<br />
'Enable all Radio buttons<br />
<br />
rbnControl10.Enabled = True<br />
<br />
rbnControl100.Enabled = True<br />
<br />
rbnControl1000.Enabled = True<br />
<br />
'Enable the two reset buttons<br />
<br />
btnDefaults.Enabled = True<br />
<br />
btnReset.Enabled = True<br />
<br />
'Post statusbar message<br />
<br />
stbControl.Text = "Game Ready!"<br />
<br />
End If<br />
<br />
'More<br />
<br />
If (intPlayerGuess) * 100 / intRandomNumber < intRandomNumber Then<br />
<br />
answer = answer<br />
<br />
End If<br />
<br />
'Less<br />
<br />
If intPlayerGuess > intRandomNumber * 100 / intPlayerGuess Then<br />
<br />
answer = answer<br />
<br />
End If<br />
<br />
'Getting Hot<br />
<br />
If answer > 96 Then<br />
<br />
txtInput.Text = ""<br />
<br />
intNoOfGuesses += 1<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "You are Hot." & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses taken so far = " & intNoOfGuesses<br />
<br />
Else<br />
<br />
txtOutput.Text = "Hot"<br />
<br />
End If<br />
<br />
End If<br />
<br />
'Getting warmer<br />
<br />
If answer > 80 Then<br />
<br />
txtInput.Text = ""<br />
<br />
intNoOfGuesses += 1<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "You are Getting Warmer." & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses taken so far = " & intNoOfGuesses<br />
<br />
Else<br />
<br />
txtOutput.Text = "Warmer"<br />
<br />
End If<br />
<br />
End If<br />
<br />
'Getting warm<br />
<br />
If answer > 64 Then<br />
<br />
txtInput.Text = ""<br />
<br />
intNoOfGuesses += 1<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "You are Getting Warm." & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses taken so far = " & intNoOfGuesses<br />
<br />
Else<br />
<br />
txtOutput.Text = "Warm"<br />
<br />
End If<br />
<br />
End If<br />
<br />
<br />
<br />
'Getting Cold<br />
<br />
If answer > 48 Then<br />
<br />
txtInput.Text = ""<br />
<br />
intNoOfGuesses += 1<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "You are Getting Cold." & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses taken so far = " & intNoOfGuesses<br />
<br />
Else<br />
<br />
txtOutput.Text = "Cold"<br />
<br />
End If<br />
<br />
End If<br />
<br />
'Getting Colder<br />
<br />
If answer > 32 Then<br />
<br />
txtInput.Text = ""<br />
<br />
intNoOfGuesses += 1<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "You are Getting Colder." & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses taken so far = " & intNoOfGuesses<br />
<br />
Else<br />
<br />
txtOutput.Text = "Colder"<br />
<br />
End If<br />
<br />
End If<br />
<br />
'Getting YsCold<br />
<br />
If answer > 16 Then<br />
<br />
txtInput.Text = ""<br />
<br />
intNoOfGuesses += 1<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "You are Getting YsCold." & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses taken so far = " & intNoOfGuesses<br />
<br />
Else<br />
<br />
txtOutput.Text = "YsCold"<br />
<br />
End If<br />
<br />
End If<br />
<br />
'Correct<br />
<br />
If answer = intRandomNumber Then<br />
<br />
txtInput.Text = ""<br />
<br />
intNoOfGuesses += 1<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "That is it, you got it, good Work." & ControlChars.CrLf & ControlChars.CrLf & "Number of guesses taken so far = " & intNoOfGuesses<br />
<br />
Else<br />
<br />
txtOutput.Text = "You are a winner"<br />
<br />
End If<br />
<br />
End If<br />
<br />
Else<br />
<br />
txtInput.Text = "" 'Clear the TextBox control<br />
<br />
'Display error if player fails to provide numeric input<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "Sorry but you entered a non-numeric guess. Please try again and be sure to enter a number this time."<br />
<br />
Else<br />
<br />
txtOutput.Text = "Numeric input required. Try again."<br />
<br />
End If<br />
<br />
End If<br />
<br />
Else<br />
<br />
txtInput.Text = "" 'Clear the TextBox control<br />
<br />
'Display error if player fails to provide input<br />
<br />
If chkVerbose.Checked = True Then<br />
<br />
txtOutput.Text = "Sorry but to play you must enter a number. Please enter higher number and try again."<br />
<br />
Else<br />
<br />
txtOutput.Text = "No input provided. try again."<br />
<br />
End If<br />
<br />
End If<br />
<br />
txtInput.Focus() 'Set focus to the TextBox control<br />
<br />
End Sub


-- modified at 3:15 Monday 11th September, 2006
AnswerRe: Persentage Pin
Guffa10-Sep-06 21:04
Guffa10-Sep-06 21:04 
Generalanybody frm kolkata working in Vb.Net 2.0 Pin
tutum10-Sep-06 20:09
tutum10-Sep-06 20:09 
QuestionKebord mapping Pin
hirenkshah10-Sep-06 19:40
hirenkshah10-Sep-06 19:40 
AnswerRe: Kebord mapping Pin
EvoFreak12-Sep-06 10:56
EvoFreak12-Sep-06 10:56 
Questionmaximize form Pin
Mr kilany10-Sep-06 9:12
Mr kilany10-Sep-06 9:12 
AnswerRe: maximize form Pin
Jun Du10-Sep-06 10:38
Jun Du10-Sep-06 10:38 
GeneralRe: maximize form Pin
Mr kilany11-Sep-06 3:57
Mr kilany11-Sep-06 3:57 
GeneralRe: maximize form Pin
EvoFreak11-Sep-06 13:40
EvoFreak11-Sep-06 13:40 
QuestionReading from text Pin
Mr kilany10-Sep-06 9:11
Mr kilany10-Sep-06 9:11 
AnswerRe: Reading from text Pin
EvoFreak10-Sep-06 10:21
EvoFreak10-Sep-06 10:21 
GeneralRe: Reading from text Pin
Mr kilany11-Sep-06 3:54
Mr kilany11-Sep-06 3:54 
GeneralRe: Reading from text Pin
EvoFreak11-Sep-06 13:25
EvoFreak11-Sep-06 13:25 
QuestionEncryption Text Pin
FriendlySoluations10-Sep-06 3:10
FriendlySoluations10-Sep-06 3:10 
AnswerRe: Encryption Text Pin
kevindotnet10-Sep-06 3:24
kevindotnet10-Sep-06 3:24 
AnswerRe: Encryption Text Pin
Dave Kreskowiak10-Sep-06 5:43
mveDave Kreskowiak10-Sep-06 5:43 
AnswerRe: Encryption Text Pin
slowbutsure2913-Sep-06 21:32
slowbutsure2913-Sep-06 21:32 
QuestionPrint by CrystalReportViewer Pin
FriendlySoluations10-Sep-06 1:59
FriendlySoluations10-Sep-06 1:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.