pickslides
New member
- Joined
- Jul 11, 2019
- Messages
- 2
- Programming Experience
- 3-5
I have designed a form using 2 textboxes and a button for a guessing game.
The user thinks of a number between 1 and 100 and the computer guesses the number.
The user replies with Y if the computer guesses, L if the number is lower and H is the number is higher
Code is not working as desired, I have no End If but the complier still runs it.
The user thinks of a number between 1 and 100 and the computer guesses the number.
The user replies with Y if the computer guesses, L if the number is lower and H is the number is higher
Code is not working as desired, I have no End If but the complier still runs it.
VB.NET:
Public Class Form1
Dim low As Integer
Dim guess As Integer
Dim high As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
low = 1
high = 100
guess = Math.Ceiling((high + low) / 2)
TextBox1.Text = "Is your number" & guess & "?"
Do Until TextBox2.Text = "Y"
guess = Math.Ceiling((high + low) / 2)
TextBox1.Text = "Is your number" & guess & "?"
If TextBox2.Text = "L" Then high = guess
If TextBox2.Text = "H" Then low = guess
Loop
End Sub
End Class