Statistica Visual Basic Syntax Reference - User-defined Functions and Subroutines (Arguments)
The general syntax for arguments in a function or subroutine declaration is:
[Public][Private] [Sub][Function] FunctionName ([ByVal | ByRef] Argument)
- ByRef
- ByRef indicates that an argument is passed by reference (see also Passing Arguments by Reference, in User-defined Functions and Subroutines in SVB). When an argument is passed by reference, the function or subroutine has access to the actual variable. As a result, the variable's value can be changed by the procedure to which it is passed, and the changed value will be passed back to the calling program, function, or subroutine.
- ByVal
- ByVal indicates that an argument is passed by value (this is the default). When an argument is passed by value, the function or subroutine only has access to a "copy" of the variable. As a result, the variable's value in the calling program cannot be changed by the procedure to which it is passed.
- ArgName
- The variable or value being passed into the function or subroutine. Arrays are passed by the name of the array followed by an empty set of parenthesis. Multiple arguments are separated by comma, and all arguments must be met (with the appropriate data type) when calling a function or subroutine.
The following example demonstrates a subroutine which requires an integer and a double precision array (one-dimensional) to be passed into it:
Sub ASubRoutine(Number As Integer,AnArray() As Double) End Sub
This subroutine can be called with the following syntax:
Dim AnArray(4) As Double Call ASubRoutine(5,AnArray())
Copyright © 2021. Cloud Software Group, Inc. All Rights Reserved.