Passing Variables by Reference

Description

It is possible to pass variables by reference, using the byref keyword. If the receiving function changes the value of the variable, the sending function will see those changes. Assume you have the following function named test().

function test as V ( byref num1 as N, byref char1 as C )
    num1 = num1 * num1
    char1 = char1 + char1
end function

You can see that the value of both num1 and char1 are changed after calling test().

dim num1 as N
dim char1 as C
num1 = 3
char1 = "Fred"
? num1
= 3.000000
? char1
= "Fred"
test(num1, char1)
? num1
= 9.000000
? char1
= "FredFred"

See Also