Examples: Call statement

Example 1

' Define a function and then invoke it in three ways.

Function MiniMult (x As Integer, y As Integer) As Integer
   MiniMult = x% * y%
End Function
Dim result As Integer

Call MiniMult(3, 4) 
       ' With Call; return value (12) is not used.
Call MiniMult 3, 4  
       ' Without Call; return value is not used.
result% = MiniMult(3, 4) ' With Call; return value is used.
Print result             ' Prints 12.

Example 2

' Define a sub and then invoke it in two ways.
Sub PrintProduct (a As Integer, b As Integer)
   Print a% * b%
End Sub
Call PrintProduct(34, 5)    ' With Call; prints 170.
PrintProduct 34, 5          ' Without Call; prints 170.