See Also Example
Transfers program control to a Visual Basic Sub procedure or a dynamic-link library (DLL ) procedure.
Call name [(argumentlist)]
The Call statement has these parts:
Call Optional keyword used to transfer program control to another procedure.
name Name of the procedure to call.
argumentlist Variables, arrays, or expressions to pass to the procedure.
You are never required to use the Call keyword when calling a procedure. If you use the Call keyword to call a procedure that requires arguments, the argument list must be enclosed in parentheses. If you omit the Call keyword, you also must omit the parentheses around the argument list.
You can pass arguments to a procedure by reference or by value. Values of arguments passed by reference can be altered by the procedure when the arguments are returned; Visual Basic supplies the actual address of the argument. Arguments passed by value are assigned a temporary address and the values cannot be altered. Arguments are passed by reference unless enclosed by parentheses or declared using the ByVal keyword.
When passing arguments to DLL procedures, you may want to pass arguments by value. Many DLL routines don't support all Visual Basic data types and ByVal will attempt a conversion. You can also use the ByVal reserved word when you declare the DLL procedure in the Declarations section. The ByVal reserved word cannot be used with a variable of a user-defined type, an object type, or a variable that is an array.
To pass a whole array, use the array name followed by empty parentheses.
Call Statement Example
The example shows two ways to call the MessageBeep procedure in USER.EXE, a Microsoft Windows DLL. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Declare Sub MessageBeep Lib "User" (ByVal N As Integer)
Sub Form_Click ()
Dim I ' Declare variable.
Call MessageBeep(0) ' Call Windows procedure.
For I = 1 To 100 : Next I ' Insert short delay between calls.
MessageBeep 0 ' Call again without Call keyword.