Passing a parameter by references

When a parameter is passed by reference, a reference to the original argument is passed to the calling procedure. The result is that if a change is made to the parameter in the passed procedure, then that changed value is passed back to the called procedure. In VBA, the default method of passing arguments is by reference. That is, if neither ByRef nor ByVal is specified then ByRef is assumed. The syntax for declaring a ByRef parameter is to insert the keyword ByRef before the parameter list is declared in the parentheses following the function name. For example, suppose we had a function called thisFunct that used a string parameter called myStr, and we wanted to pass this parameter by reference, then the declaration would be:

Function thisFunct (ByRef myStr as String)

0 0

Post a comment