O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 If...Then...Else statement

End Property

Marks the end of a Property Let, Property Get, or Property Set procedure within a Class...End Class construct

End Select

Marks the end of a Select Case statement

End Sub

Marks the end of a Sub procedure

End With

Marks the end of a With statement

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required