Public Class Form1
Private Sub btnGuess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuess.Click
Dim guess As Integer
Dim x As Integer
Static intCount As Integer
intCount = intCount + 1
If intCount = 1 Then
lblNumber.Text = "You've guessed " & intCount & " time."
Else
lblNumber.Text = "You've guessed " & intCount & " times."
End If
guess = CInt(txtGuess.Text)
Randomize()
x = CInt(Int((100 * Rnd()) + 1))
If guess = x Then
' Generate random value between 1 and 100.
x = CInt(Int((100 * Rnd()) + 1))
intCount = 0
lblGuess.Text = "You geussed it!"
Else
If guess > x Then
lblGuess.Text = "Guess lower."
Else
If guess < x Then
lblGuess.Text = "Guess Higher."
End If
2007-03-08
13:25:10
·
1 answers
·
asked by
Daddyhorhay
1
in
Computers & Internet
➔ Programming & Design
Do I just use the onLoad function? Can I make the generator only happen when the form is opened? Feel free to put in the proper code and I can give it a try
2007-03-08
13:27:10 ·
update #1
Visual Basic. I want a random number at the opening of the program and then a new one only when i guess the correct number. Right now I am getting a new random every time I guess (click btnGuess after typing a number into txtGuess). You guys are awesome by the way on answering my previous questions.
2007-03-08
13:42:11 ·
update #2