Code

Sub Guess()

tr = Application.InputBox(“Enter the Number of Tries”, , , , , , , 1)
Min = Application.InputBox(“Enter the Min Number”, Type:=1)
Max = Application.InputBox(“Enter the Max Number”, Type:=1)
g = Int(Rnd() * Max)

Do While tr _ 0
i = Application.InputBox(“Enter an Number between ” & Min & ” and ” & Max, Type:=1)

If Val(i) = g Then
MsgBox “Congrats you guessed the number. It was ” & g
Exit Sub
ElseIf i = False Then
Exit Sub
Else
If Val(i) _ Min And Val(i) _ g Then Min = Val(i)
If Val(i) _ Max And Val(i) _ g Then Max = Val(i)
End If

tr = tr – 1
Loop

MsgBox “Sorry you didn’t guess the Number ” & g

End Sub

Chris Terrell

View all posts