1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| Sub devine_nombre()
Dim nombre As Integer
Dim i As Byte
i = 0
nombre = 0 + Rnd * (1001)
saisie = InputBox("Veuillez donner un nombre compris entre 0 et 1000", , "Saisie du nombre")
If nombre = saisie Then
MsgBox "bravo, vous avez gagné"
Else
While nombre <> saisie And i < 12
If saisie < nombre Then
ActiveSheet.Shapes("AutoShape 8").Select
Selection.Characters.Text = "Trop petit!!!"
With Selection.Characters(Start:=1, Length:=32).Font
.Name = "Blackadder ITC"
.FontStyle = "Normal"
.Size = 36
End With
saisie = InputBox("Donner un autre nombre", , "Saisie du nombre")
i = i + 1
Else
ActiveSheet.Shapes("AutoShape 8").Select
Selection.Characters.Text = "Trop grand!!!"
With Selection.Characters(Start:=1, Length:=32).Font
.Name = "Blackadder ITC"
.FontStyle = "Normal"
.Size = 36
End With
saisie = InputBox("Donner un autre nombre", , "Saisie du nombre")
i = i + 1
End If
Wend
End If
If nombre = saisie Then
ActiveSheet.Shapes("AutoShape 8").Select
Selection.Characters.Text = "Bravo!!!"
With Selection.Characters(Start:=1, Length:=32).Font
.Name = "Blackadder ITC"
.FontStyle = "Normal"
.Size = 36
End With
Else
ActiveSheet.Shapes("AutoShape 8").Select
Selection.Characters.Text = "Perdu!!!"
With Selection.Characters(Start:=1, Length:=32).Font
.Name = "Blackadder ITC"
.FontStyle = "Normal"
.Size = 36
End With
End If
End Sub |
Partager