From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Language Keyword

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


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.


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)

See Also

Method Setters topic; Extends command; Assigns can only be used on the last parameter Error.