Passing arrays to SUBs and FUNCTIONs 
Author Message
 Passing arrays to SUBs and FUNCTIONs

Could someone post a summary of the syntax for passing arrays to SUBs and
FUNCTIONs and which arrays can be passed (someone posted earlier saying that
he thought that control arrays couldn't be passed)? I've looked in the
manuals, the on-line help, the FAQ and the KB that comes with VB PE, but to no
avail.

Thanks very much,

Robert Owen



Mon, 05 Jan 1998 03:00:00 GMT  
 Passing arrays to SUBs and FUNCTIONs

Quote:

>Could someone post a summary of the syntax for passing arrays to SUBs and
>FUNCTIONs and which arrays can be passed (someone posted earlier saying that
>he thought that control arrays couldn't be passed)? I've looked in the
>manuals, the on-line help, the FAQ and the KB that comes with VB PE, but to no
>avail.

To my knowledge, you cannot pass control arrays.

To pass other arrays to subs,

        Call subToGetArray( myArray() )  ' must use 'Call' keyword

        subToGetArray ( array() as String )   'must declare type

RLH
Sr. P/A
Smith Barney Inc. NYC
Equity Systems Services
--
"In what distant deeps or skies       |     Ryan L. Heil

 On what wings dare he aspire?        |  
 What the hand dare seize the fire?"  | - William Blake 1793(1794) -



Mon, 05 Jan 1998 03:00:00 GMT  
 Passing arrays to SUBs and FUNCTIONs
Quote:
>Could someone post a summary of the syntax for passing arrays to SUBs
>and FUNCTIONs and which arrays can be passed (someone posted earlier
>saying that he thought that control arrays couldn't be passed)? I've

looked >in the manuals, the on-line help, the FAQ and the KB that comes
with VB PE, >but to no avail.

You cannot pass control arrays to a sub.  However, you can pass a control
array element, i.e., Sub_Name controlname(1)

To pass normal arrays to subs or functions, just pass the array name
followed by (), i.e.,

.... calling procedure

Name_of_Sub ArrayName()

.........

Sub Name_of_Sub ArrayName () as ???????????

?????? is the type of the array such as integer, string, userdefined, etc.

Note that one of the replies you recieved to your query suggested that
you had to use the Call keyword to call a sub where an array is passed.  
This is incorrect.  You need not use the key word.

_____________________________________________________
"Keep an Open Mind and People will throw in Garbage"



Mon, 05 Jan 1998 03:00:00 GMT  
 Passing arrays to SUBs and FUNCTIONs
Quote:

>To pass other arrays to subs,

>    Call subToGetArray( myArray() )  ' must use 'Call' keyword

                                           ^^^^^^^^^^^^^^^^^^^^^^^
this isn't true... you can pass arrays to subs without using the "call"
keyword if you call it with
"subToGetArray myArray()"

Quote:

>    subToGetArray ( array() as String )   'must declare type

note: the calling sub or function must also have declared the array
to be of the same type as the parameter otherwise VB will crash out
with an error

Quote:
>RLH
>Sr. P/A
>Smith Barney Inc. NYC
>Equity Systems Services

-------------------------------------------------------------------------------

"There was a point to this narrative, but it has presently escaped
 the chronicler's mind."   --Douglas Adams
--
-------------------------------------------------------------------------------

"There was a point to this narrative, but it has presently escaped
 the chronicler's mind."   --Douglas Adams


Wed, 07 Jan 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. pass an array as function/sub argument

2. Question on passing array parameters to VB.NET Sub/Function

3. Passing array back from Sub/Function

4. Passing arrays from a server-function/sub to a server -variable

5. pass an array as function/sub argument

6. Pass control array to sub/function ?

7. Passing Arrays to Sub / Functions

8. Passing Control Array to a SUB/FUNCTION

9. Passing arrays in a sub/function

10. Calling a sub or function using a variable through another sub or function

11. Returning sub or function name within a specific sub or function

12. Local function/sub inside function/sub

 

 
Powered by phpBB® Forum Software