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

Sub Statement

Syntax

[Public [Default] | Private] Sub name [(arglist)] 
   [statements]
   [Exit Sub] 
   [statements]
End Sub
Public

Use: Optional

Type: Keyword

Gives the sub procedure visibility to all scripts. If used in a class definition, the sub procedure is also accessible from outside the class. Public and Private are mutually exclusive.

Default

Use: Optional

Type: Keyword

Indicates that a public procedure defined in a VBScript class (that is, defined within a Class...End Class construct) is the default member of the class.

Private

Use: Optional

Type: Keyword

Restricts the visibility of the sub procedure to those procedures within the same script. In a class definition, restricts the visibility of the sub procedure to the class itself. Public and Private are mutually exclusive.

name

Use: Required

The name of the sub procedure.

arglist

Use: Optional

Data Type: Any

A comma-delimited list of variables to be passed to the sub procedure as arguments from the calling procedure.

statements

Use: Optional

Program code to be executed within the sub procedure.

arglist uses the following syntax and parts:
[ByVal | ByRef] varname[( )]
ByVal

Use: Optional

The argument is passed by value; that is, a local copy of the variable is assigned the value of the argument.

ByRef

Use: Optional

The argument is passed by reference; that is, the local variable is simply a reference to the argument being passed. All changes made to the local variable are also reflected in the calling argument. ByRef is the default method of passing variables. ...

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