newcoder1010

How to return an array

2 posts in this topic

Hi,

I am trying to return an array and then print it. It is printing blank values. Can you please help? Thanks.

 

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

 

function ArrayExample (key,totalKey) dim x() ReDim x(totalKey) For i = key to totalKey x(key) = i ArrayExample = x(key) Next end function key = 2 totalKey = 4' dim y() ReDim y(totalKey) y(totalKey) = ArrayExample (key,totalKey) For i = key to totalKey msgbox y(key) Next

Edited by newcoder1010

Share this post


Link to post
Share on other sites

You're not returning an array from your function, you're returning a single value.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now