Pour arrêter une boucle Do ... Loop ou For ... Next
a) Affectez "True" à la propriété KeyPreview de la fenêtre.
b) Créez une variable globale style Public ArrêtBoucle as boolean
b) Prévoyez une ligne z=Doevents() dans la boucle.
c) Revoyez le code de la boucle : Do ... Loop While ArrêtBoucle = False ou juste
avant le Next
If ArrêtBoucle = True Then
Exit For
End If
d) Dans la procédure Form_KeyPress(KeyAscii As Integer). Ajoutez ArrêtBoucle = True
Note : Vous pouvez choisir le code Ascii de la touche (Esc=27 ...)