Exit Statement

Exits a Do...Loop, For...Next, a function, a property, or a subroutine.

Syntax:

Exit Do, Exit For, Exit Function, Exit Property, Exit Sub

Parameters:

Exit Do

Do...Loop 문 내에서만 유효하며 루프를 종료합니다. Loop 문 뒤에 오는 문에서 프로그램 실행이 계속됩니다. Do...Loop 문이 중첩된 경우 콘트롤이 다음 상위 수준의 루프로 이동합니다.

Exit For

For...Next 루프 내에서만 유효하며 루프를 종료합니다. Next 문 다음에 오는 첫 번째 문에서 프로그램이 실행이 계속됩니다. 중첩된 문에서는 제어가 다음 상위 수준의 루프로 이동합니다.

Exit Function

Function 프로시저를 즉시 종료합니다. Function 호출 뒤에 오는 문에서 프로그램 실행이 계속됩니다.

Exit Property

Exits the Property procedure immediately. Program execution continues with the statement that follows the Property call.

Exit Sub

서브루틴을 즉시 종료합니다. Sub 호출 뒤에 오는 문에서 프로그램 실행이 계속됩니다.

참고 아이콘

Exit 문은 구조의 끝을 지정하지 않으며 End 문과 혼동해서는 안 됩니다.


Example:

Sub ExampleExit
Dim sReturn As String
Dim sListArray(10) As String
Dim siStep As Single
    For siStep = 0 to 10 REM Fill array with test data
        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
REM LinSearch searches a TextArray:sList() for a TextEntry:
REM Returns the index of the entry or 0 ( Null)
    For iCount=1 To Ubound( sList() )
        If sList( iCount ) = sItem Then
            Exit for REM sItem found
        End If
    Next iCount
    If iCount = Ubound( sList() ) Then iCount = 0
    LinSearch = iCount
End Function

Please support us!