The terms parameter and argument are often used interchangeably, although they have entirely different meanings. Let us illustrate with an example. Consider the following function, which replicates a string a given number of times:
sInputAs String, ByVal
iCountAs Integer) _ As String Dim i As Integer For i = 1 To
iCountRepeatString = RepeatString &
sInputNext End Function
iCount are the parameters of this
function. Note that each parameter has an associated data type.
Now, when we call this function, we must replace the parameters by variables, constants, or literals, as in:
s = RepeatString("Donna", 4)
The items that we use in place of the parameters are called arguments.
Arguments can be passed to a function in one of two ways: by value or by reference. Incidentally, argument passing is often called parameter passing, although it is the arguments and not the parameters that are being passed.
The declaration of RepeatString given earlier
contains the keyword
ByVal in front of
each parameter. This specifies that arguments are passed by value to
this function. Passing by value means that the actual value of the
argument is passed to the function. This is relevant when an argument
is a variable. For instance, consider the following code:
x= x + 1 End Sub Dim
iAgeAs Integer = 20 Inc(
The final line:
actually displays the number ...