Name
End . . . Statement
Syntax
End Class End Function End If End Property End Select End Sub End Type End With
Description
Ends a procedure or a block of code.
Rules at a Glance
The End statement is used as follows:
|
Statement |
Description |
|---|---|
|
|
Terminates program execution |
|
|
Marks the end of a class definition |
|
|
Marks the end of a Function procedure |
|
|
Marks the end of an |
|
|
Marks the end of a Property Let, Property Get, or Property Set
procedure within a |
|
|
Marks the end of a |
|
|
Marks the end of a Sub procedure |
|
|
Marks the end of a |
Programming Tips & Gotchas
The End statement used by itself to terminate the
program is not supported within a VBScript script or procedure.
Instead you should terminate execution of a procedure prematurely
using the Exit... statement. You can also
terminate the script or application by calling a method belonging to
an object of the object model you are using. These are shown in the
following table:
|
Environment |
Method |
|---|---|
|
ASP |
Response.End or Session.Abandon |
|
IE |
Application.Quit |
|
Outlook form |
Item.Close |
|
Windows Script Host |
WScript.Quit |
VBA/VBScript Differences
VBA supports the End statement, which immediately
terminates execution of code and, in the case of Visual Basic,
terminates the application. The End statement,
however, is not supported in VBScript.
See Also
| Exit Statement |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access