From Xojo Documentation

Language Keyword

Used to pass a parameter by value. This is the default for parameters so this is completely optional.


ByVal parameter

Part Type Description
parameter Any Data Type Parameter to be passed by value.


Parameters passed by value are treated as local variables inside the method-just like variables that are created using the Dim statement. This means that you can modify the values of the parameters themselves rather than first assigning the parameter to a local variable. For example, if you pass a value in the parameter "x", you can increment or decrement the value of x rather then assigning the value of x to a local variable that is created using Dim.

To pass a parameter by reference, you use the ByRef keyword in the parameter declaration for the method. If you precede a parameter name by the keyword ByRef, you pass information by reference. When you pass information by reference, you actually pass a pointer to the variable containing the information. The practical advantage of this technique is that the method can change the values of each parameter. When you pass parameters by value, it doesn't do this because in effect the parameter only represents a copy of the data itself.

All arrays and objects are passed by reference, not copied, so changes to that array or object will be reflected in the calling method. This is no different than assigning an array or object to a second variable or property.

See Also

ByRef keyword.