DIAdem Help

Content Type
Programming Language
Current manual
Table of Contents

Exit Statement

Exit Statement

Use the Exit statement to abort a loop or a procedure. You can define as many Exit statements as you like anywhere in a loop or in a procedure.

When you abort a For..Next, For..Each..Next, Do While..Loop, or Do..Loop Until loop, the script continues the execution with the statement that follows Next or Loop. When you abort a Function, Sub or Property procedure, the script continues the execution with the statement that follows the call of that procedure.

Exit For
Exit Do
Exit Function
Exit Sub
Exit Property

The following example shows how you can abort a loop:

Dim i, MyVal
MyVal = CInt(InputBox("Please enter a value (0-1000)"))
For i = 1 to 1000
  If i = MyVal Then
   Call MsgBox("Value = " & i)
   Exit For
  End If 
Next

Related Topics

Do While...Loop | Do...Loop Until | Exit | For...Next | For Each...Next | If...Then...Else | Select Case...Case...End Select | While...Wend | With

In This Section
Was this information helpful?