Parameter List
Gives the parameters that a caller must supply before a procedure executes. 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
orunit
.
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
Method DoAnotherThing
Method GetInt%
Method GetInteger As Integer
Method GetStr$()
Method GetString() As String
One or more mandatory parameters
Method DoSomethingWith number
Method ChangeStr ByRef str$
Method GetSomethingFrom[T](#con As MyContainer[T]) As T
One or more optional parameters
Method