Link to home
Start Free TrialLog in
Avatar of samsonite1023
samsonite1023

asked on

Passing array through subs and functions.

Hi.

I have a dynamic array, and would like to pass it to a sub or function, how can I do so?
sub main()
dim array() as string

redim array(1 to 10)

call subroutine1(array)
end sub


public sub subroutine1(newarray() as string)

end sub

This doesnt work!


Thanks for helping me out.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it should work fine the way it is, are you actually calling it array() in your program?  Because that's a reserved word, if you are try changing the name.
Avatar of samsonite1023
samsonite1023

ASKER

Just a big mistake on my part!  I had it right on here, but in my actual code I left out the "Call" keyword.

So stupid!

Apparently without the "Call" keyword, it won't work.

Anyone know why?  I thought leaving Call out was perfectly fine.

Thanks

-Sam
you may omit the Call but in this case, omit the parentheses too.