Keyword

Assigns


Description

Used to indicate that a value will be passed via a parameter to a method with the Assignment operator.

Usage

Assigns parameter As DataType

Part

Type

Description

parameter

The name of the parameter being declared.

DataType

Any valid data type

The data type of the parameter.

Notes

Use the Assigns keyword when you want to assign a value to a parameter of a method with the equals sign rather than as an argument.

The Assigns keyword can appear in a Method declaration dialog box for the only parameter passed to the method or for the last parameter, if more than one parameter is being passed. When Assigns is used, you use a different syntax when calling the method. The value for the Assigns parameter must be passed using the assignment operator rather than as an argument.

Do not use a return type on a function with an Assigns parameter as you won't be able to access the return value due to the assignment syntax.

Sample code

The following declaration uses Assigns for the last parameter:

Sub ChangeValue(a As Integer, b As Integer, Assigns c As Integer)

When this method is called, only the values for a and b are passed as arguments; the value for c is passed using the assignment operator. For example:

ChangeValue(5, 4) = 10

This usage results in a syntax error when Assigns is used:

ChangeValue(5, 4, 10)

Compatibility

All project types on all supported operating systems.