Call Statement

Syntax

[Call] procedurename [argumentlist]


Call

Use: Optional


procedurename

Use: Required

Data Type: n/a

The name of the subroutine being called.


argumentlist

Use: Optional

Data Type: Any

A comma-delimited list of parameters to pass to the subroutine being called.

Description

Passes execution control to a procedure, function, or dynamic-link library (DLL) procedure.

Rules at a Glance

  • Components of argumentlist may include the keywords ByVal or ByRef to describe how the arguments are treated by the called procedure. However, ByVal and ByRef can be used with Call only when calling a DLL procedure defined with the Declare statement. ByRef indicates that the variable's address in memory, rather than its value, is to be passed to the external routine; this means that, should the external routine modify the variable's value, this change is reflected in the variable's value when the external DLL routine returns control to the calling procedure. ByVal, on the other hand, indicates that the parameter is passed to the DLL routine by value ; in other words, a copy of the value, rather than its location in memory, is passed to the external library routine. This means that, if the parameter is a variable, the external routine can't modify its value. (An exception is a string expression that's passed by value to a DLL routine. All strings are passed by reference to external DLLs; however, a string passed using the ByVal keyword is passed by reference as a C string; whereas a string passed using the ByRef keyword is passed by reference as a Visual Basic string.)

  • You aren't 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 omit the Call keyword from the procedure call, you must also omit the parentheses around argumentlist.

  • If you use either Call syntax to call any intrinsic or user-defined function, the function's return value is discarded.

Example

Call myProcedure(True, iMyInt)

Sub myProcedure(blnFlag as Boolean, iNumber as Integer)
...
End Sub

Programming Tips and Gotchas

  • To pass a whole array to a procedure, use the array name followed by empty parentheses.

  • Your code will be easier to read and understand if you explicitly use the Call keyword.

See Also

Sub Statement, Function Statement
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.35.178