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