Call Statement

Syntax

[Call] procedurename [argumentlist]

Call

Use: Optional

procedurename

Use: Required

Data Type: n/a

The name of the subroutine being called.

argumentlist

Use: Optional

Data Type: Any

A comma-delimited list of parameters to pass to the subroutine being called.

Description

Passes execution control to a procedure, function, or dynamic-link library (DLL) procedure.

Rules at a Glance

  • Components of argumentlist may include the keywords ByVal or ByRef to describe how the arguments are treated by the called procedure. However, ByVal and ByRef can be used with Call only when calling a DLL procedure defined with the Declare statement. ByRef indicates that the variable's address in memory, rather than its value, is to be passed to the external routine; this means that, should the external routine modify the variable's value, this change is reflected in the variable's value when the external DLL routine returns control to the calling procedure. ByVal, on the other hand, indicates that the parameter is passed to the DLL routine by value ; in other words, a copy of the value, rather than its location in memory, is passed to the external library routine. This means that, if the parameter is a variable, the external routine can't modify its value. (An exception is a string expression that's passed by value to a DLL routine. All strings are passed by reference to external DLLs; however, a string passed using the ByVal keyword is passed by reference as a C string; whereas ...

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.