Comment sortir d'une boucle (Do loop, for next ...)

jmdelhalle Messages postés 24 Date d'inscription mercredi 22 janvier 2003 Statut Membre Dernière intervention 8 janvier 2005 - 24 déc. 2004 à 16:24
zizouhiba Messages postés 5 Date d'inscription lundi 15 juin 2009 Statut Membre Dernière intervention 24 janvier 2016 - 2 mai 2011 à 18:55
Bonjour
Comment faire pour sortir d'une boucle (sans quitter la procédure ou la fonction en cours) avant la fin du traitement

tant que toto <> 0
.../...
.../...
si struc = 1 alors
sortir
fin

fin

' oncontinue
../...

:) JM

4 réponses

Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
24 déc. 2004 à 16:52
Exit For pour une boucle For ... Next
Exit Do pour une boucle Do ... Loop

Daniel
0
jmdelhalle Messages postés 24 Date d'inscription mercredi 22 janvier 2003 Statut Membre Dernière intervention 8 janvier 2005
28 déc. 2004 à 11:30
ok merci pour tout
:) JM
0
zizouhiba Messages postés 5 Date d'inscription lundi 15 juin 2009 Statut Membre Dernière intervention 24 janvier 2016
2 mai 2011 à 16:54
Bonjour,

Je voudrait sortir d'une boucle que je lance avec command1 en utilisant command2. J'ai essayé ça mais ça ne marche pas :

Dim fin As Boolean

Private Sub Command1_Click()
Do
Text1.Text = Str(Time)

Loop Until fin = True

End Sub

Private Sub Command2_Click()
fin = True

End Sub

Merci de m'aider.
0
zizouhiba Messages postés 5 Date d'inscription lundi 15 juin 2009 Statut Membre Dernière intervention 24 janvier 2016
2 mai 2011 à 18:55
J'ai trouvé la solution :

Il suffisait d'ajouter DoEvents :

Dim Fin As Boolean

Private Sub Form_Load()
Text1.Text = Str(Time)
End Sub

Private Sub Command1_Click()
Fin = False
Do While (Not Fin)
Text1.Text = Str(Time - T1)
DoEvents
Loop
End Sub

Private Sub Command2_Click()
Fin = True
End Sub
0
Rejoignez-nous