2.7 Parameters and Arguments 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: Function RepeatString(ByVal sInput As String, ByVal iCount As Integer) _ As String Dim i As Integer For i = 1 To iCount RepeatString = RepeatString & sInput Next End Function The variables sInput and 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. 2.7.1 Passing 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: Sub Inc(ByVal x As Integer) x = x + 1 End Sub Dim iAge As Integer = 20 Inc(iAge) Msgbox(iAge) The final line: Msgbox(iAge) actually displays the number 20. In other words, the line: Inc(iAge) does nothing. The reason is that the argument iAge is passed to the procedure Inc by value. Since only the value (in this case 20) is passed, that value is assigned to a local variable named x within the procedure. This local variable is increased to 21, but once the procedure ends, the local variable is destroyed. The variable iAge is not passed to the procedure, so its value is not changed.
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check Actions tomcat hosting services