Name
Call Statement
Syntax
[Call]procedurename[argumentlist]
CallUse: Optional
Use: Required
Data Type: n/a
The name of the subroutine being called.
argumentlistUse: Optional
Data Type: Any
A comma-delimited list of arguments to pass to the subroutine being called.
Description
Passes program control to an explicitly named procedure or function.
Rules at a Glance
The
Callstatement requires that the procedure being called be named explicitly. You cannot assign the subroutine name to a variable and provide that as an argument to theCallstatement. For example, the following is an illegal use ofCall:Dim sProc sProc = "PrintRoutine" Call sProc(sReport) ' Illegal: sProc is a variable
The following code fragment shows a valid use of the
Callstatement:Call PrintRoutine(sReport) ' Legal usage
You aren’t required to use the
Callkeyword when calling a function procedure. However, if you use theCallkeyword to call a procedure that requires arguments,argumentlistmust be enclosed in parentheses. If you omit theCallkeyword from the procedure call, you must also omit the parentheses aroundargumentlist.
Example
The WSH code fragment shows a call to a procedure that passes
two arguments: a string array and a string. Note that while the call
to the ShowList procedure uses the Call keyword, the equivalent call to the
MsgBox function within the ShowList procedure does not:
Dim aList, sCaption aList = Array("One", "Two", "Three", "Four") sCaption = "Array Contents" Call ShowList(aList, sCaption) Sub ShowList(arr( ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access