Sub Bouton1_QuandClic()
Dim nombre As Integer
Dim cpt As Byte
Dim bon As Boolean
Dim propo As Integer
nombre = Int((1000 * Rnd) + 1)
bon = False
Do
propo = Application.InputBox('Merci de faire une proposition ?', Type:=1)
If propo = 0 Then Exit Sub
If propo > nombre Then MsgBox 'le chiffre à trouver est plus petit que ' & propo: cpt = cpt + 1
If propo < nombre Then MsgBox 'le chiffre à trouver est plus grand que ' & propo: cpt = cpt + 1
If propo = nombre Then
cpt = cpt + 1
MsgBox 'Bravo, vous avez trouvé !!!' & vbNewLine & cpt & ' tentatives'
bon = True
End If
Loop Until bon = True
End Sub