Sortir d'une boucle

L’instruction Exit permet de quitter un bloc Do...Loop, For...Next, Function, ou Sub. Sa syntaxe est la suivante :

Exit Do

Exit For

Exit Function

Exit Sub

Exemple :

La boucle suivante s’arrête lorsque la réponse rep est n ou N :

Do

Rep = InputBox("Voulez-vous continuer ? (O/N)")

If LCase(rep) = "n" Then Exit Do

Loop

Modifié le: lundi 14 novembre 2016, 18:43