Call (statement)


Call subroutine_name [(arguments)]


Transfers control to the given subroutine, optionally passing the specified arguments.


Using this statement is equivalent to:

subroutine_name [arguments]

Use of the Call statement is optional. The Call statement can only be used to execute subroutines; functions cannot be executed with this statement. The subroutine to which control is transferred by the Call statement must be declared outside of the Main procedure, as shown in the following example.


This example demonstrates the use of the Call statement to pass control to another function.

Sub Example_Call(s$)

  'This subroutine is declared externally to Main and displays the text
  'passed in the parameter s$.
  MsgBox "Call: " & s$
End Sub

Sub Main()

  'This example assigns a string variable to display, then calls subroutine
  'Example_Call, passing parameter S$ to be displayed in a message box
  'within the subroutine.
  s$ = "DAVE"
  Example_Call s$
  Call Example_Call("SUSAN")
End Sub

See Also

Goto (statement); GoSub (statement); Declare (statement).

More information