Utiliser un Select Case pour la lisibilité : voir aide en ligne
ainsi qu'un Randomize en début de procédure
la fonction devrait ressembler à qqch comme
Private Function Jeu(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer) As Integer
Dim iTotal As Integer, iScore As Integer
iTotal = a + b + c
Select Case iTotal
.... à toi de completer
End Select
Jeu = iScore
End Function
Sub dé()
Dim x As Integer
Dim y As Integer
Dim z As Integer
....
x = Int((Rnd * 6) + 1)
y = Int((Rnd * 6) + 1)
z = Int((Rnd * 6) + 1)
'Debug.Print x, y, z, Jeu(x, y, z)
MsgBox ("les 3 lancés sont" & " " & x & " " & y & " " & z & " " & "vous avez gagné" & " " & Jeu(x, y, z) & " " & "points" )
End Sub
|