| Start |
|---|
| Passing Simple Variables ByRef And ByVal Passing If an argument is passed If an argument is passed A simple example will illustrate this clearly: Another example: |
ByRef Default modifierIf no modifier is specified for a parameter, that parameter is implicitly passed by reference. The Watch out! If you're coming to VBA with experience from other languages, this is very likely the exact opposite behavior to the one you're used to. In many other programming languages (including VB.NET), the implicit/default modifier passes parameters by value. Passing by referenceCalling the above ByRef, the procedure receives a reference to the pointer. The above code raises run-time error 91 (opens new window), because the caller is calling the Forcing ByVal at call siteUsing parentheses at the call site, you can override The above code outputs 42, regardless of whether Watch out! Because of this, using extraneous parentheses in procedure calls can easily introduce bugs. Pay attention to the whitespace between the procedure name and the argument list: |
| Passing Arguments ByRef or ByVal The Note In many other programming languages (including VB.NET), parameters are implicitly passed by value if no modifier is specified: consider specifying |
Read Article
https://develop.horje.com/learn/1434/reference