Private Sub Command1_Click()
Dim secret As Integer
Dim choice As Integer
Dim counter As Integer

counter = 0

secret = Int(1000 * Rnd)
Do
    choice = InputBox("please guess the magic number")
        If choice > secret Then
            MsgBox (" Your value is too High")
        ElseIf choice < secret Then
            Print MsgBox("your value is too low")
            
        End If
counter = counter + 1
Loop Until choice = secret
Print MsgBox("yes that is the correct value and it took you " & (counter) & " goes to get it")
End Sub

    Source: geocities.com/matkins70