Sub Procedures

A Sub procedure is a series of ViviFire statements enclosed by Sub and End Sub clauses.

The Sub procedure performs a task, then returns control to the calling code (known as the "caller"). The procedure does not return a value to the caller.

Each time the procedure is called, its statements are executed, beginning with the first executable statement after the Sub clause. Execution normally proceeds until it encounters the End Sub clause; however, it can be halted by either an Exit Sub or Return statement.

You can define a Sub procedure in modules, classes, objects, and traits. It is private, meaning that it can be called only by other code in the enclosing class, object, or trait, or module if not otherwise enclosed.

A Sub procedure can take arguments, such as constants, variables, or expressions, which are passed to it by the caller.

Declaration syntax

Sub sub_name [ parameter_list ]
    ' statements
End Sub

Parameter declaration

Parameters as local variables

Calling syntax

Example of declaration and call

See also