In this challenge we clean up this code by adding a prompt for tries, min, and max. Also see if you can handle the exit if cancel is pressed.

Here is the code from #1
===============
Sub Guess()

g = Int(Rnd() * 25)

tr = 5
Min = 0
Max = 25

Do While tr _ 0
i = InputBox(“Enter an Number between ” & Min & ” and ” & Max)

If Val(i) = g Then
MsgBox “Congrats you guessed the number”
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