The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Call Statement

Transfers control to a Sub procedure, Function procedure, or dynamic-link library (DLL) procedure.

[ Call ] ProcedureName[(ArgumentList)]


Required. Name of the procedure to call.
Optional. List of variables or expressions representing arguments that are passed to the procedure when it is called. Multiple arguments are separated by commas. If you include ArgumentList, you must enclose it in parentheses.


You are not required to use the Call keyword when calling a procedure; however, if you use the Call statement to call any intrinsic, DLL, or user-defined function, the function's return value is discarded.


This example illustrates how the Call statement is used to transfer control to a Sub procedure, an intrinsic function, and a dynamic-link library (DLL) procedure.

' Call a Sub procedure.
Call PrintToDebugWindow("Hello World")   
' The above statement passes control to the following Sub procedure.
Sub PrintToDebugWindow(ByVal AnyString As String)
   Debug.WriteLine(AnyString)   ' Print to the Output window.
End Sub

' Call a Visual Basic run-time function (Shell), discard the return value.
Call Shell("C:\WINNT\system32\calc.exe", AppWinStyle.NormalFocus)
' The preceding path is for Windows 2000;
' The Windows XP path C:\Windows\system32\calc.exe.

' Call a Microsoft Windows DLL procedure. The Declare statement must be 
' Private in a class, not in a module.
Private Declare Sub MessageBeep Lib "User32" (ByVal N As Integer)
Sub CallMyDll()
   Call MessageBeep(-1)   ' Call Windows DLL procedure.
   MessageBeep(-1)   ' Call again without Call keyword.
End Sub

See Also

Declare Statement | Function Statement | Sub Statement

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft