<< Prev        Next >>

ID : 3746

Exit

Function

To exit a designated processing block.

Syntax

Exit block name

Guaranteed Entry

Block name
Designate a block name to exit. Designate any of Sub, Function, Do and For.

Description

You exit a designated block.

Blocks that can be designated in block name are listed below.

Designation Block
Exit Do Do...Loop statement
Exit For For...Next statement
Exit Sub Sub...End Sub procedure
Exit Function Function...End Function procedure

Attention

If Do...Loop or For...Next is nested, call an outer loop next to the loop with Exit.

Example

'!TITLE "Compulsory Exit from For...Next"
' Compulsory exit from For...Next
Sub Sample_ExitFor

  Dim aaa As Integer

  For aaa = 0 To 10

    ' Exit the loop once conditions are met
    If aaa = 5 Then Exit For

  Next

  ' Display a value at the time of exit from the loop on the message output window
  PrintDbg aaa

End Sub

ID : 3746

<< Prev        Next >>