Interruption d'un boucle for a l'aide d'un botton

yr1r13762 Messages postés 19 Date d'inscription lundi 1 septembre 2008 Statut Membre Dernière intervention 10 septembre 2008 - 2 sept. 2008 à 09:00
jrivet Messages postés 7392 Date d'inscription mercredi 23 avril 2003 Statut Membre Dernière intervention 6 avril 2012 - 2 sept. 2008 à 09:23
salut
je veu savoir comment j peut faire une interruption d'un boucle for a l'aide d'un botton dans userform en vba
merci
je compte sur vous

1 réponse

jrivet Messages postés 7392 Date d'inscription mercredi 23 avril 2003 Statut Membre Dernière intervention 6 avril 2012 60
2 sept. 2008 à 09:23
Salut,
C'est bien parce que c'est le début de journée... Mais en cherchant un peu dans le forum tu aurais trouvé SEUL.

Private Interrupt As Boolean

Private Sub CommandButton1_Click()
'Lors de l'appui sur Interrupt passe a TRUE
'et donc la boucle plus bas terminera
   Interrupt = True
End Sub<hr />

Private Sub UserForm_Activate()
Dim i As Integer
   For i = 1 To 30000
       DoEvents
       Label1.Caption = CStr(i) 'pour bien voir que la boucle fonction
       If Interrupt Then Exit For
   Next
   Call MsgBox("Sorti de la Boucle")
End Sub<hr />
, ----
[code.aspx?ID=41455 By Renfield]

@+: Ju£i€n
Pensez: Réponse acceptée
0
Rejoignez-nous