Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub CommandButton1_Click()
- Dim guess1 As Integer
- Dim guess2 As Integer
- Dim secret As Integer
- secret = Me.Cells(1, 2)
- guess1 = InputBox("Lower Bound:")
- guess2 = InputBox("Upper Bound:")
- While midpt <> secret
- midpt = (guess1 + guess2) / 2
- If midpt - secret > 0 Then
- guess2 = midpt
- midpt = (guess1 + guess2) / 2
- Else
- If midpt - secret < 0 Then
- guess1 = midpt
- midpt = (guess1 + guess2) / 2
- If midpt = secret Then
- MsgBox ("The secret number is " & secret)
- Else
- End If
- End If
- End If
- Wend
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement