Keyword

# Assigns

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to indicate that a value will be passed via a parameter to a method with the `Assignment</api/language/equals>` operator.

## Usage

``` xojo
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 <span class="title-ref">Assigns</span> keyword when you want to assign a value to a parameter of a method with the equals sign rather than as an argument.

The <span class="title-ref">Assigns</span> keyword can appear in a `Method</api/language/sub>` 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 <span class="title-ref">Assigns</span> is used, you use a different syntax when calling the method. The value for the <span class="title-ref">Assigns</span> parameter must be passed using the assignment operator rather than as an argument.

Do not use a return type on a function with an <span class="title-ref">Assigns</span> parameter as you won't be able to access the return value due to the assignment syntax.

## Sample code

The following declaration uses <span class="title-ref">Assigns</span> for the last parameter:

``` xojo
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:

``` xojo
ChangeValue(5, 4) = 10
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This usage results in a syntax error when <span class="title-ref">Assigns</span> is used:

``` xojo
ChangeValue(5, 4, 10)
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Method Setters</getting_started/using_the_xojo_language/methods/setters>` topic; `Extends</api/language/extends>` command; `Assigns can only be used on the last parameter</api/errors>` Error.

</div>
