Declaration specifier to explicitly pass a parameter by reference
Syntax
Usage
Description
Passes a variable by reference, that is its address, to a subroutine or function. When a variable is passed by reference, the contents of the variable can be changed by the target subroutine or function.
In
-lang qb and
-lang fblite dialects,
ByRef is the default parameter passing convention, unless
Option ByVal is in effect.
Opposite of
ByVal.
Example
Dim MyVar As Integer
Sub ChangeVar(ByRef AVar As Integer)
AVar = AVar + 1
End Sub
MyVar = 1
Print "MyVar: "; MyVar 'output = 1
ChangeVar MyVar
Print "MyVar: "; MyVar 'output = 2
Sleep
End
Dialect Differences
- In -lang fb dialect, ByVal is the default parameter passing convention for all built-in types except String and user-defined Type which are passed ByRef by default.
- In -lang qb and -lang fblite dialects, ByRef is the default parameter passing convention.
Differences from QB
See also