ID : 127
Exit
功能
退出指定的处理数据块。
解说
退出指定的数据块。
可通过数据块名指定的数据块如下所示。
指定 | 数据块 |
---|---|
Exit Do | Do...Loop语句 |
Exit For | For...Next语句 |
Exit Sub | Sub...End Sub过程 |
Exit Function | Function...End Function过程 |
注意事项
Do...Loop和For...Next形成嵌套时,将控制移动至有Exit循环的一个外侧循环。
应用示例
'!TITLE "强制从For~Next中退出"
' 强制从For~Next中退出
Sub Sample_ExitFor
Dim aaa As Integer
For aaa = 0 To 10
' 与条件一致时退出循环
If aaa = 5 Then Exit For
Next
' 在讯息输出视窗中显示退出循环时的值
PrintDbg aaa
End Sub
ID : 127