Return

From Xojo Documentation

Language Keyword

Returns flow of execution to the calling method.

Usage

Return [value]

Part Type Description
value Any Value returned to the calling function.

The data type must be specified in the Function declaration.

Notes

Methods automatically return when you reach the end of the code in the method. You can use the Return command to exit a method early based on a condition. You must specify a return value for functions and events that are declared to have a return value. The return value must match the type in the declaration. The return value can be an array or a single value. If you want to return an array, put empty parentheses after the name of the data type in the Return Type area for the declaration in the Inspector. For example, if you want to return an array of Integers, this would be the return type:

If you need to return a multi-dimensional array, place one fewer commas in the parentheses than dimensions. For example, to return a two-dimensional array of Doubles, use this as the return type:

Sample Code

// Exit early from a method
Sub Test(value As Text)
If value = "Hello" Then Return

Label1.Text = value
End Sub

// Return from a function
Function calc(value As Integer) As Integer
value = value * 2
Return value
End Sub

See Also

Exit, Function, Sub statements.