End Statement

Ends a procedure or block.

Syntax

End

End Function

End If

End Select

End Sub

The End statement syntax has these forms:

Statement Description
End Terminates running the script. It's not required, but can be placed anywhere in the program for closing files, opened with Open, and for clearing variables.
End Function Required statement to close the Function construction.
End If Required statement to close the IfÅThenÅElse construction.
End Select Required statement to close the Select Case construction.
End Sub Required statement to close the Sub construction.

Remarks

The End statement resets all variables at the module level and all static local variables in all modules. Current-level script stops running, which causes script on lower execution levels stop running too. For instance, if the End statement was performed in the document's script, scripts at the Page and Shape level immediately stop running.

If you need to save values of global variables and leave the program waiting for its procedure calls, you should use the Stop statement.

Note: The End statement immediately stops execution of the script. Files open with the Open statement are closed, and memory used by the program is cleared.

Example

In the example below the End statement is used to terminate the program if the user provides an incorrect password.

Sub EndSample()
Dim Pword

const PassWord = "password"

Pword = InputBox("Enter password")

If Pword <> PassWord Then MsgBox "Illegal password" End ' Stops program execution
End If
End Sub

 

See Also

Function Statement, If ... Then ... Else Statement, Select Case Statement , Stop_Statement, Sub Statement