
Call Statement | 183
The Language
Reference
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Example
Public Sub Main( )
DoSomeLongFunction( )
Beep( )
MsgBox("Finished!")
End Sub
Call Statement
Syntax
[Call] procedureName([argumentList])
procedureName (required)
The name of the subroutine being called
argumentList (optional)
A comma-delimited list of arguments to pass to the subroutine being called
Description
The Call statement passes execution control to a procedure, function, or dynamic-link
library (DLL) procedure or function.
Usage at a Glance
• Use of the Call keyword is optional.
• argumentList, if present, must always be enclosed in parentheses.
• If you use Call to call a function, the function’s return value is discarded.
Example
Call SomeProcedure(True, importantData)
...later...
Public Sub SomeProcedure(ByVal silentFlag As Boolean, _
ByVal workData As Integer)
...
End Sub
Version Differences
• In VB 6, calls to subroutines only included parentheses around the argument list
when the
Call keyword was included. In .NET, parentheses are required when-
ever arguments are present.
• In VB 6, when calling an external routine defined using the
Declare statement,
you could override the defined method of passing an argument by specifying the
ByVal or ByRef keywords before the argument in the Call statement. In .NET, you
cannot change the argument-passing ...