Call Statement
Visual Basic Language Reference 
Call Statement (Visual Basic) 

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

[ Call ] procedureName [ (argumentList) ]
procedureName

Required. Name of the procedure to call.

argumentList

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 normally use the Call statement to call a procedure that does not return a value. If the procedure returns a value, the Call statement discards it.

You are not required to use the Call statement when calling a procedure. However, it improves the readability of your code.

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.

Visual Basic
        ' (1) Call a Sub procedure.
        Call printToDebugWindow("Hello World")
<br /><span space="preserve">...</span><br />
    ' The above statement passes control to the following Sub procedure.
    Sub printToDebugWindow(ByVal anyString As String)
        Debug.WriteLine(anyString)
    End Sub
Visual Basic
' (2) 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 is C:\Windows\system32\calc.exe.
Visual Basic
' (3) 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 callBeepDll()
    Call MessageBeep(-1)
End Sub
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
Page view tracker