Guys,
I have a 2d array of (x,1) elements could anyone tell me how to determine how many rows the array has?
I've written a a function which adds records in but I won't know how many have been returned.
Thanks
Guys,
I have a 2d array of (x,1) elements could anyone tell me how to determine how many rows the array has?
I've written a a function which adds records in but I won't know how many have been returned.
Thanks
If you haven't set the Option Base then the array is 0 based which means that the "rows" are x+1 (0 item included) and the "columns" are 1+1.
If you have set Option Base 1 then you have x and 1.
Is that what you're asking?
He didn't know it was impossible, so he did it. (Jean Cocteau)
Thanks for the quick response.
Basically my function will return an array of (x,1) - so I know i'll definitely have 2 cols and x amount of rows
so for example i'll have an array which will consist of something like this
array(0,0) = 34
array(1,0) = 23
array(2,0) = 67
array(..,0) = x
array(0,1) = 22
array(1,1) = 12
so col 0 has 3 rows and 1 has 2.. rows
So I know how many columns i'm dealing with becuase I defined that already but i'm not sure how many rows i'll be dealing with... so my function will pass back this array but with an undetermined number of rows.
So is it possible to say how many rows does array(x,0) have and array(x,1)?
Or to ask another way, is there a way to loop through a 2 column array with undefined rows?
Hope that makes sense!
To find the dimensions of your 2d array, after it is returned by the function, use
[vba]MsgBox Ubound(ArrayName,1) and Ubound(ArrayName,2)[/vba]
After that, as I said before, take also into account the Option Base setting.
To loop through the "rows" of the array use
[vba] for i = lbound(array) to ubound(array)[/vba]
He didn't know it was impossible, so he did it. (Jean Cocteau)