Call Statement
Updated: April 2009
Transfers control to a Sub or Function procedure.
[Call] name [argumentlist]
You are not required to use the Call keyword when calling a procedure. However, if you use the Call keyword to call a procedure that requires arguments, argumentlist must be enclosed in parentheses. If you use either Call syntax to call any intrinsic or user-defined function, the function's return value is discarded.
The following example illustrates the use of the Call statement.
Dim retValue
' Call the function with and without the "Call" keyword.
Call ShowSum(3, 4)
ShowSum 5, 6
' Omitting the "Call" keyword allows access
' to the function's return value.
retValue = ShowSum(7, 8)
MsgBox "The function returned: " & retValue
Function ShowSum(value1, value2)
Dim sum
' Determine and display the sum.
sum = value1 + value2
MsgBox "The sum is: " & sum
' Set the function's return value.
ShowSum = sum
End Function
Community Additions
Show: