Parameter List

Gives the parameters that a caller must supply before a procedure runs. For more than one parameter, you must put a comma between each one.

Syntax

Without parentheses

mandatory_parameters [ , Optional optional_parameters ]

With parentheses

( [ mandatory_parameters [ , Optional optional_parameters ] ] )

Parts

mandatory_parameters

Mandatory parameter

[ ByRef ] declarator
optional_parameters

Optional parameter

[ ByRef ] declarator [ = default_value ]
declarator

Declarator

name [ ( [ * rank ] ) ] [ As type | In unit ]
ByRef
Optional modifier (short for "by reference") lets the passed argument have its value changed by the procedure. Thus the parameter becomes an alias of the argument. Without this, the parameter is a copy of the argument. But objects and arrays are always passed by reference.
name
Mandatory identifier that becomes a local variable to the procedure.
rank
Optional integer literal. Specifies the number of dimensions of the passed array.
type
Optional data type
unit
Optional unit of measure
default_value
Optional constant of a type compatible with type or unit.

Instructions

TODO

Examples

The examples that follow use procedures of the type Method, but this makes no difference. Also, the lines End Method are not given to help show the parameter syntax.

No parameters

Method DoSomething
    ' Does not return a value.
Method GetNumber%
    ' Returns an integer.
Method GetNumber() As Int32
    ' This is almost the same as above, with more verbosity.

One or more mandatory parameters

Method Increment amount As Int32
    ' Has one mandatory parameter passed by value.
    ' Does not return a value.
Method GetPoint(ByRef x As Int32, ByRef y As Int32)
    ' Has two parameters passed by reference.
    ' Does not return a value.
    ' The parentheses are optional.
Method AddStudent(name As String) As Int32
    ' Has one parameter passed by value.
    ' Returns an integer value.
    ' String is a reference type.
    ' The parentheses are mandatory.

One or more optional parameters

Method AddStudent name As String, Optional dob As DateTime
    ' Has one mandatory and one optional parameter.
    ' Does not return, thus parentheses are optional.
    ' If dob is not supplied by the caller,
    ' it has its default value.

See also