在vb中用于强制退出for循环的语句是什么。

2024-12-12 21:52:03
推荐回答(2个)
回答1:

1。加个过程就可以,这样的好处是你不需要在循环上写那么多的判断代码!
For a = 0 To 100
Ok
Next a
Private Sub Ok()
For b = 0 To 100
For c = 0 To 100
If Text1.txt = "I Love You" Then Exit Sub
End If
Next c
Next b
End Sub
2。使用行跳转
For a = 0 To 100
For b = 0 To 100
For c = 0 To 100
If Text1.txt = "I Love You" Then
Goto OK
End If
Next c
Next b
ok:
Next a
3.使用变量检查
For a = 0 To 100
For b = 0 To 100
If Ok then Exit For
For c = 0 To 100
If Text1.txt = "I Love You" Then
OK = True
Exit For
End If
Next c
Next b
Next a

回答2:

exit for