j'ai vite faite une example :
Private Sub Command1_Click()
MsgBox Me.Random_Prio(1, 10) End Sub
Function Random_Prio(Lowerbound As Integer, Upperbound As Integer) As Integer Dim test As Boolean Dim temp As Integer Dim temp2 As Integer 'Stop Randomize temp = Int((Upperbound * Rnd) + Lowerbound) ' si temp = 3 => 3x le boucle For x = 1 To temp ' temp/2 or temp/3 est aussi possible temp2 = (temp2 + Int((2 * Rnd) + 1)) - 1 Next x ' si apres 3x temp2 ets encore 0 => return temp If temp2 = 0 Then Random_Prio = temp 'Exit Function Else 'Stop Random_Prio = Random_Prio(Lowerbound, Upperbound) End If End Function
' +++ stevebelgium
------------------------------- Réponse au message : -------------------------------
> J'aimerais savoir s'il n'existe pas une fonction ou autre qui me permettrait de sortir des chiffres avec une priorité. > Ex: > mes chiffres 1,2,3,4,5,6 > le 1 doit sortir plus souvent que le 2 > le 2 doit sortir plus souvent que le 3 > le tout de maniére aléatoire >
|