Dim Noparticip As Integer Dim ListeNombre() As Integer Dim Nombre As Integer Dim Texte As String Dim i As Integer Dim x As Integer Dim Continue As Boolean Dim nb As Integer Private Sub Command1_Click() 'Vide le champ de texte Text1.Text = vbNullString Text3.Text = vbNullString 'Initialise la fonction Rnd Randomize 'Dimentionne le Tableau ReDim ListeNombre(0) 'Insert un nombre 0 pour la premiere instance ListeNombre(0) = 0 nb = Val(Text2) For i = 1 To nb Continue = False Do While Continue = False DoEvents ' Genere un nombre aleatoire entre 1 et text1.text Nombre = Int((Rnd * Text2.Text) + 1) ' Met la valeur de sorti de boucle sur True Continue = True ' Verifie si il n'y a pas de double For x = LBound(ListeNombre) To UBound(ListeNombre) If ListeNombre(x) = Nombre Then ' Si le nombre existe deja on met sur False Continue = False End If Next x Loop 'Redimentionne le Tableau en preservant les valeurs ReDim Preserve ListeNombre(i) 'Insert le nouveau nombre ListeNombre(i) = Nombre Next i 'On rempli le champs list List1.Clear For i = 1 To nb - 1 Step 2 List1.AddItem Text1.Text & ListeNombre(i) & " - " & ListeNombre(i + 1) Next Randomize If nb Mod 2 = 1 Then Noparticip = Int(Rnd * nb + 1) Text3 = Noparticip List1.AddItem Text1.Text & CStr(Nombre & " - ") End If End Sub Private Sub Command2_Click() nb = nb - 1 For i = Noparticip To nb ListeNombre(i) = ListeNombre(i + 1) Next ListeNombre(i) = 0 List1.Clear For i = 1 To nb Step 2 List1.AddItem Text1.Text & ListeNombre(i) & " - " & ListeNombre(i + 1) Next End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim Noparticip As Integer Dim ListeNombre() As Integer Dim Nombre As Integer Dim i As Integer Dim x As Integer Dim Continue As Boolean Dim nb As Integer Private Sub Command1_Click() ' Vide le champ de texte Text1.Text = vbNullString Text3.Text = vbNullString ' Initialise la fonction Rnd Randomize nb = Val(Text2) ' Dimentionne le Tableau ReDim ListeNombre(nb) For i = 1 To nb Continue = False Do While Continue = False DoEvents ' Genere un nombre aleatoire entre 1 et text1.text Nombre = Int((Rnd * Text2.Text) + 1) ' Met la valeur de sorti de boucle sur True Continue = True ' Verifie si il n'y a pas de double For x = 1 To i - 1 If ListeNombre(x) = Nombre Then ' Si le nombre existe deja on met sur False Continue = False Exit For End If Next x Loop ' Insert le nouveau nombre ListeNombre(i) = Nombre Next i ' On rempli le champs list List1.Clear For i = 1 To nb - 1 Step 2 List1.AddItem Text1.Text & Format(ListeNombre(i), "00") & " - " & Format(ListeNombre(i + 1), "00") Next Randomize If nb Mod 2 = 1 Then Noparticip = Int(Rnd * nb + 1) Text3 = Noparticip List1.AddItem Text1.Text & Format(Nombre, "00") & " - " End If End Sub Private Sub Command2_Click() If Noparticip = 0 Then Exit Sub nb = nb - 1 For i = Noparticip To nb ListeNombre(i) = ListeNombre(i + 1) Next ListeNombre(i) = 0 List1.Clear For i = 1 To nb Step 2 List1.AddItem Text1.Text & Format(ListeNombre(i), "00") & " - " & Format(ListeNombre(i + 1), "00") Next End Sub