Call Statement

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

Syntax

[Call] name ([argumentlist])

The Call statement syntax has these parts:

Part Description
Call Optional; keyword. Supported for compatibility with other versions of BASIC.
name Required. Name of the procedure to call.
argumentlist Optional. Comma-delimited list of variables, array items, or expressions to pass to the procedure. Components of argumentlist may include the keywords ByVal or ByRef to describe how the arguments are treated by the called procedure.

Remarks

You are not required to use the Call keyword when calling a procedure. However, if you use the Call keyword to call a procedure that requires arguments, argumentlist must be enclosed in parentheses. If you use either Call syntax to call any intrinsic or user-defined function, the function's return value is discarded.

Example

This example illustrates how the Call statement is used to transfer control to a Sub procedure, an intrinsic function.

Declare Sub PrintToOutputWindow(AnyString As String)


' Call a Sub procedure.
Call PrintToOutputWindow("Hello World")   
' The above statement causes control to be transfered to the following
' Sub procedure.
Sub PrintToOutputWindow(AnyString As String)
   Trace AnyString   ' Print to the Output window.
End Sub

' Call is an intrinsic function. The returned value of the function is discarded.
Call MsgBox("Call an intrinsic MsgBox function")

 

See Also

Declare Statement , Function Statement , Sub Statement