Collabora Office 21.06 帮助
Exits a Do...Loop, For...Next, a function, a property, or a subroutine.
Exit Do, Exit For, Exit Function, Exit Property, Exit Sub
Exit Do
仅在「Do...Loop」语句内有效,作用是退出循环。程序继续执行 Loop 语句之后的语句。如果「Do...Loop」语句是嵌套语句,控制将传递到下一个较高级别的循环中。
Exit For
仅在「For...Next 循环内有效,作用是退出循环。程序继续执行 Next」语句之后的第一条语句。在嵌套语句中,控制将传递到下一个较高级别的循环中。
Exit Function
立即退出「函数」过程。程序继续执行「函数」调用之后的语句。
Exit Property
Exits the Property procedure immediately. Program execution continues with the statement that follows the Property call.
Exit Sub
立即退出子例程。程序继续执行「子程序」调用之后的语句。
Exit 语句不能定义程序结构的结束,请勿与 End 语句混淆。
Sub ExampleExit
Dim sReturn As String
Dim sListArray(10) As String
Dim siStep As Single
For siStep = 0 To 10 ' 用测试数据填充数组
sListArray(siStep) = chr(siStep + 65)
MsgBox sListArray(siStep)
Next siStep
sReturn = LinSearch(sListArray(), "B")
Print sReturn
End Sub
Function LinSearch( sList(), sItem As String ) As Integer
Dim iCount As Integer
' LinSearch 搜索 TextArray:sList() 中的 TextEntry:
' 返回条目的索引或 0 (Null)
For iCount=1 To Ubound( sList() )
If sList( iCount ) = sItem Then
Exit For ' 找到 sItem
End If
Next iCount
If iCount = Ubound( sList() ) Then iCount = 0
LinSearch = iCount
End Function