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

ចេញ​ពី​បែបបទ អនុគមន៍ ភ្លាម​ៗ ។ ដំណើរ​ការ​ប្រតិបត្តិ​បន្ត​ជាមួយ​សេចក្តី​ថ្លែង​ការណ៍ ដែល​នៅ​បន្ត​ពី​ការ​ហៅ អនុគមន៍ ។

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