[COLOR="DarkSlateGray"][B]Private Sub UserForm_Initialize()
Dim Fichier As String
Dim x As Long
InitJeu [COLOR="SeaGreen"]'Pour éviter de commencer systématiquement avec zéro.[/COLOR]
Fichier = ThisWorkbook.Path & "\image.ico" [COLOR="SeaGreen"]' Fonctionne si l'image est dans le même dossier que le classeur.[/COLOR]
x = Len(Dir(Fichier))
If x = 0 Then Exit Sub
x = ExtractIconA(0, Fichier, 0)
SendMessageA FindWindow(vbNullString, Me.Caption), &H80, False, x
End Sub
Private Sub OK_Click()
Dim rep As Long
On Error GoTo E [COLOR="SeaGreen"]'Pour éviter le plantage en cas d'absence de saisie ou en cas de saisie non numérique.[/COLOR]
If CInt(Nombres.Text) < nbAlea Then
Textes.Caption = "C'est plus !"
Nombres.SetFocus
Else
If CInt(Nombres.Text) > nbAlea Then
Textes.Caption = "C'est moins !"
Nombres.SetFocus
Else
If CInt(Nombres.Text) = nbAlea Then
Textes.Caption = "Bravo ! C'était bien le " & nbAlea
Nombres.SetFocus
rep = MsgBox("Voulez-vous recommencer ?", vbYesNo, "Jeu - Plus ou Moins")
If rep = vbNo Then
Unload Me
End
Else
InitJeu
End If
End If
End If
End If
R: Nombres.Text = ""
Exit Sub
E: On Error GoTo 0: Resume R [COLOR="SeaGreen"]'Traitement de l'erreur.[/COLOR]
End Sub[/B][/COLOR]