Table of Contents

Call Statement

Syntax

Call procedureName([argument1, argument2, ...])

Description

The Call statement is used to invoke Sub, Function, or Property procedures in Visual Basic. Although optional, it can improve code readability, especially when passing ByRef arguments or when you want to clearly indicate that a procedure call is being made.

  Note: In VB6, using Call requires that arguments be enclosed in parentheses. If you don't use Call, parentheses are only required if a return value is expected.

Parameters

Examples

No return value (Sub):

Sub ShowMessage()
    MsgBox "Hello from a procedure."
End Sub
 
' Call using Call
Call ShowMessage
 
' Call without Call (also valid)
ShowMessage

With arguments:

Sub Greet(name As String)
    MsgBox "Hello, " & name
End Sub
 
Call Greet("Carlos")    ' Using Call with parentheses
Greet "Carlos"          ' Without Call, no parentheses

With return value (Function):

Function Add(a As Integer, b As Integer) As Integer
    Add = a + b
End Function
 
Dim result As Integer
 
result = Add(5, 10)      ' Without Call, return value is used
 
Call Add(5, 10)          ' Valid, but return value is discarded

Remarks

See Also

Sub Statement

Function Statement

MsgBox Function