Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

returning an array

Status
Not open for further replies.

vasah20

Programmer
Feb 16, 2001
559
US
hi -
do you guys know how to return an array from a function?
I've tried doing functionName = myArray, but that doesn't seem to return the array to the calling function (IsArray fails in the calling function, but succeeds in the called function.)

ex:
function myfunction()
dim myArray(25)
...
myfunction = myArray
end function

if isarray(myfunction) then '<-- this always fails

any ideas?
leo
 
I executed this as a VBS with a double click and I get an &quot;Array&quot; message.
Code:
If Isarray(myfunction) then
    msgbox &quot;array&quot;
else
    msgbox &quot;No Array&quot;
End if
function myfunction()
 dim myArray(25)
 myfunction = myArray
end function
 
Just ran same code on PWS - win98, and also get &quot;array&quot;
penny.gif
penny.gif
 
Hm -
ok... I'll take a closer look at my code. Maybe there's a logic error that I overlooked... thanks
 
What about returning an array and assigning it to another array?

Function myFunc(param1, param2)

dim array(11)
...
myFunc = array
End Function

....
dim otherArray(11)

otherArray = myFunc(param1, param2) ' I get a type mismatch error on this line

Thanks,
Ray
 
fengshui1998 answered this, you dim the second one like so:

dim otherArray
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top