Parameters are passed to ByVal
unless explicitly specified. For more details, see Passing Arguments by Value and by Reference , which states:
By default, in Visual Basic, you must pass arguments by value. You can make code easier to read with the ByVal keyword. Good programming practice includes either the ByVal keyword or ByRef with each parameter declared.
Concerning:
What if I have a complex object passed as a value?
This is great if the โcomplex objectโ is a class (link type), you are not going to copy a lot. This is because the reference to the instance of the object is passed by value (ByVal), which means that you copy only one link, even if the class is very large.
If, however, the complex object is a structure (value type), you will force the object to be copied when the method is called. This is due to the fact that some structures, such as XNA, provide alternative versions of many methods (for example, Matrix.Multiply ) that can transmit ByRef
- this avoids costly copies of matrix structures.
source share