Search here for all the info you want in this Blog

Passing Arguments


Passing Arguments


VBScript has the following rules on passing arguments to function and subroutine procedures:
1. By default, arguments are passed by reference. In this case, an argument name can be used as a variable that referring (sharing) the same data as the calling code.
2. But, arguments can be passed by value, if you put the key word "ByVal" before the argument name. In this case, an argument name can be used as a variable that contains a copy of the data provided by the calling code.
3. Of course, you put the word "ByRef" before an argument name to declare a pass-by-reference argument explicitly.
4. A pass-by-reference argument can be used to allow the procedure to alter data that is associated with a variable in the calling code. This allows the procedure to output data back to the calling code.
5. A pass-by-value argument is safer than a pass-by-reference argument, because the procedure only gets a copy of the data. Any changes to that data will not affect the original data in the calling code.
6. Arrays can be passed by reference.
7. Arrays can also be passed by value. In this case, the procedure will get a copy of the array.

          pass byval

          pass byref

No comments:

Post a Comment