Return Statement

This statement causes a user-define procedure to return control the the calling procedure and optionally return a value.
Return[value]

Prerequisites

Return can only appear within a procedure.

Parameters

value

The value to be returned to the calling procedure if the current procedure is a Function. The value field must be specified in a Function procedure. It must not be specified in Sub procedure.

Remarks

The current procedure exits when it encounters a Return statement and execution continues with the calling procedure. If there is no calling procedure, the current thread is terminated with success. In a function procedure, a Return is equivalent to assigning a value to the function-name variable followed by an Exit Function statement.

Examples

Function add_function (x As Integer, y As Integer) As Integer
Return x+y
End Function



Sub add_sub (x As Integer, y As Integer, ByRef result As Integer)
result = x+y
Return
End Sub

See Also

Statements |Exit Function statement | Exit Sub statement