# Return Statement (Visual Basic)

Returns control to the code that called a Function, Sub, Get, Set, or Operator procedure.

## Syntax

Return
' -or-
Return expression


## Part

expression
Required in a Function, Get, or Operator procedure. Expression that represents the value to be returned to the calling code.

## Remarks

In a Sub or Set procedure, the Return statement is equivalent to an Exit Sub or Exit Property statement, and expression must not be supplied.

In a Function, Get, or Operator procedure, the Return statement must include expression, and expression must evaluate to a data type that is convertible to the return type of the procedure. In a Function or Get procedure, you also have the alternative of assigning an expression to the procedure name to serve as the return value, and then executing an Exit Function or Exit Property statement. In an Operator procedure, you must use Return expression.

You can include as many Return statements as appropriate in the same procedure.

Note

The code in a Finally block runs after a Return statement in a Try or Catch block is encountered, but before that Return statement executes. A Return statement cannot be included in a Finally block.

## Example

The following example uses the Return statement several times to return to the calling code when the procedure does not have to do anything else.

Public Function GetAgePhrase(ByVal age As Integer) As String
If age > 60 Then Return "Senior"
If age > 40 Then Return "Middle-aged"
If age > 20 Then Return "Adult"
If age > 12 Then Return "Teen-aged"
If age > 4 Then Return "School-aged"
If age > 1 Then Return "Toddler"
Return "Infant"
End Function
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.20715133845806122, "perplexity": 2484.741686474213}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2022-40/segments/1664030337889.44/warc/CC-MAIN-20221006222634-20221007012634-00716.warc.gz"}