fbrt
Messages postés39Date d'inscriptionlundi 25 février 2002StatutMembreDernière intervention16 avril 2005
-
22 avril 2002 à 13:49
fbrt
Messages postés39Date d'inscriptionlundi 25 février 2002StatutMembreDernière intervention16 avril 2005
-
22 avril 2002 à 14:45
Bonjour a tous
Je cherche un moyen pour arreter une boucle For pendant son execution a partir d'un bouton annuler. Si je mets un bouton , son évenement est pris en compte a la fin de la boucle et non pendant.
cs_Cath
Messages postés27Date d'inscriptionsamedi 13 avril 2002StatutMembreDernière intervention26 novembre 2005 22 avril 2002 à 14:15
Salut,
Pour que le click soit pris en compte pendant la boucle, il faut placer DoEvents entre For et Next.
Par exemple :
Private Sub Command1_Click()
Command1.Tag = "Stop"
End Sub
Private Sub Form_Click()
Dim I As Long
For I = 1 To 2000000
Print Str$(I)
DoEvents
If Command1.Tag = "Stop" Then
Command1.Tag = ""
MsgBox Str$(I)
Exit For
End If
Next
End Sub