用 goto 简单for i = 1 to n for each x in y for j = 1 to n if ...then goto ForOver End If next j next x next i ForOver:
dim s as boolean for i = 1 to n for each x in y for j = 1 to n if ...then s=true exit for next j if s=true then exit for next x if s=true then exit for next i
建议用1楼的GOTO,这种情况搞一堆exit for看着太累了
for i = 1 to n do for each x in y for j = 1 to n if ...then exit do '跳到i循环 next j next x exit do loop next i
Sub XXX() for i = 1 to n for each x in y for j = 1 to n if ...then Exit Sub End If next j next x next i End Sub
for each x in y
for j = 1 to n
if ...then
goto ForOver
End If
next j
next x
next i
ForOver:
dim s as boolean
for i = 1 to n
for each x in y
for j = 1 to n
if ...then
s=true
exit for
next j
if s=true then exit for
next x
if s=true then exit for
next i
do
for each x in y
for j = 1 to n
if ...then exit do
'跳到i循环
next j
next x
exit do
loop
next i
Sub XXX()
for i = 1 to n
for each x in y
for j = 1 to n
if ...then
Exit Sub
End If
next j
next x
next i
End Sub