Name

Sub Statement

Syntax

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

Use: Optional

Type: Keyword

Gives the subprocedure scope through all procedures in all modules in the project. If used within a createable class module, the sub procedure is also accessible from outside the project. 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 scope of the subprocedure to those procedures within the same module. Public, Private, and Friend are mutually exclusive.

name

Use: Required

The name of the subprocedure.

arglist

Use: Optional

Data Subtype: Any

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

statements

Use: Optional

Program code to be executed within the subprocedure.

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.

varname

Use: Required ...

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.