Name
End . . . Statement
Syntax
End Class End Function End If End Property End Select End Sub End With
Description
Ends a procedure or a block of code.
Rules at a Glance
The End statement is used
as follows:
Statement | Description |
End Class | Marks the end of a class definition |
End Function | Marks the end of a Function procedure |
End If | Marks the end of an |
End Property | Marks the end of a Property Let, Property Get,
or Property Set procedure within a |
End Select | Marks the end of a |
End Sub | Marks the end of a Sub procedure |
End With | Marks the end of a |
Programming Tips and 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
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