Name
Call Statement
Syntax
[Call]procedurename[(argumentlist)]
-
procedurename(required; n/a) The name of the subroutine being called
-
argumentlist(optional; any) A comma-delimited list of arguments to pass to the subroutine being called
Description
Passes execution control to a procedure, function, or dynamic-link library (DLL) procedure or function
Rules at a Glance
Use of the
Callkeyword is optional.Regardless of whether the
Callkeyword is used,argumentlist, if it is present, must be enclosed inparentheses.If you use
Callto call a function, the function’s return value is discarded.
Example
Call myProcedure(True, iMyInt) Sub myProcedure(blnFlag as Boolean, iNumber as Integer) ... End Sub
Programming Tips and Gotchas
To pass a whole array to a procedure, use the array name followed by empty parentheses.
Some programmers suggest that code is more readable when the
Callkeyword is used to call subroutines.
VB.NET/VB 6 Differences
In VB 6, parentheses had to be omitted if the
Callkeyword was omitted andprocedurenamehad more than one argument. In VB.NET, parentheses are required whenever arguments are present.In VB 6, if
argumentlistconsisted of a single argument, enclosing it in parentheses and omitting theCallstatement reversed the method by which the argument was passed to the called function. Thus, an argument ordinarily called by value would be called by reference, and vice versa. In VB.NET, this confusing behavior is not supported.In VB 6, when calling an external routine ...
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