Sub Statement


Sub SubName [(arguments)]
       Dim [variable(s)]
       [statementblock]
       [Exit Function]
End Sub

Declares and defines a Sub procedure name, parameters and code.

When the optional argument list needs to be passed the format is as follows:

([ByVal] variable [As type] [,ByVal] variable [As type] ]…])

The optional ByVal parameter specifies that the variable is [passed by value instead of by reference

SEE ByRef and ByVal in Scripting Language Elements for more information.

The optional As Type parameter is used to specify the data type.  Valid types are String, Integer, Double, Long, and Varaint (see “Variable Types” in this manual).  

Example:

    Sub Main

        Dim DST As String

        DST = "t1"

        mkdir DST

        mkdir "t2"

    End Sub


Related Topic:

Call Statement

Dim Statement