Compartilhar via


Call Statement

Transfers control to a Sub or Function procedure.

[Call] name [argumentlist]

Arguments

  • Call
    Optional keyword. If specified, you must enclose argumentlist in parentheses. For example:

    Call MyProc(0)

  • name
    Required. Name of the procedure to call.

  • argumentlist
    Optional. Comma-delimited list of variables, arrays, or expressions to pass to the procedure.

Remarks

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.

Example

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

Requirements

Version 1

Change History

Date

History

Reason

April 2009

Modified syntax information in "Remarks" section.

Content bug fix.

April 2009

Modified example.

Customer feedback.