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

Only valid within a Do...Loop statement to exit the loop. Program execution continues with the statement that follows the Loop statement. If Do...Loop statements are nested, the control is transferred to the loop in the next higher level.

Exit For

Only valid within a For...Next loop to exit the loop. Program execution continues with the first statement that follows the Next statement. In nested statements, the control is transferred to the loop in the next higher level.

Exit Function

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

Exit Property

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

Exit Sub

Exits the subroutine immediately. Program execution continues with the statement that follows the Sub call.

Note Icon

The Exit statement does not define the end of a structure, and must not be confused with the End statement.


Example:


Sub ExampleExit
Dim sReturn As String
Dim sListArray(10) As String
Dim siStep As Single
    siStep = 0 සිට 10 දක්වා REM පරීක්ෂණ දත්ත සමඟ අරාව පුරවන්න
        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 TextEntryක් සඳහා TextArray:sList() සොයයි :
REM ආපසු ලබා දෙන අගය ප්‍රවේශයේ සුචිය හෝ 0 (කිසිවක් නැත) වේ
    For iCount=1 To Ubound( sList() )
        If sList( iCount ) = sItem Then
            REM sItem සඳහා ඉවත්වීමක් හමුවිය
        End If
    Next iCount
    If iCount = Ubound( sList() ) Then iCount = 0
    LinSearch = iCount
End Function

Please support us!