作者:--Zqf | 来源:互联网 | 2023-05-19 09:35
代码就像
'first for loop
for I = 1 to 5
do sth
'second for loop
for j = 2 to 7
do sth
'third for loop
for m = 2 to 43
if [condition] then
exit 2nd and 3rd loop and continue on next I ?????
end if
next
next
next
我写了两个"退出",但它没有帮助.它只退出第3个循环并继续下一个j.
1> Kyle..:
如果在循环中嵌套一个标志,则可以在循环第二个循环之前放置一个if语句.如果该标志为true,那么您也退出第二个循环.
'first for loop
for I = 1 to 5
do sth
'second for loop
for j = 2 to 7
do sth
'third for loop
for m = 2 to 43
if [condition] then
flg = True
Exit for
end if
next
If flg = True then Exit For
next
next