I'm trying to create computer guess game in which i think number between 1-100 and computer generate random number between 1-100 and user give response that generated number is too low or too high or correct guess.E.G computer generate number 23 if i give input L then next time it will generate number between 1 t0 23.If next time if it display 10 then i press H then it will generate numbers between 10 and 23 hope you understand what i am trying to do.And same for H. Thanks Here is my code i try
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Declare Variables
Dim strGuess As Char
Dim random As New Random
Dim answer As Integer
Dim low As Integer
Dim high As Integer
Line1:
MessageBox.Show("You pick a number between 0 and 100 and i will try to guess.Respond")
answer = random.Next(1, 100)
strGuess = InputBox("Is it " & answer, "Number Guessing Game")
' lstGuesses.Items.Add(strGuess)'
low = answer
Line2:
If (CChar(strGuess) = CChar("L")) Then
low = random.Next(1, low)
strGuess = InputBox("Is it " & low, "Number Guessing Game")
End If
GoTo Line2
high = answer
Line7:
If (CChar(strGuess) = CChar("H")) Then
high = random.Next(high, 100)
strGuess = InputBox("Is it " & high, "Number Guessing Game ")
End If
GoTo Line7
End Sub
Aucun commentaire:
Enregistrer un commentaire