question about arrays

R

Rick Charnes

I've declared a one-dimensional, fixed-size array and assigned values to
SOME but not all of its elements. I know UBound() will return the upper
bound of the array. Is there a function that will return to me the
index number of the highest-numbered element **for which I've actually
assigned a value**? Thanks.
 
K

Karl E. Peterson

Rick Charnes said:
I've declared a one-dimensional, fixed-size array and assigned values to
SOME but not all of its elements. I know UBound() will return the upper
bound of the array. Is there a function that will return to me the
index number of the highest-numbered element **for which I've actually
assigned a value**? Thanks.

No. You'd have to roll yer own. Just loop backwards through the array, looking for
the first that isn't set to a default value, then bump by one.
 
J

Jay Freedman

No. You'd have to roll yer own. Just loop backwards through the array, looking for
the first that isn't set to a default value, then bump by one.

Or maintain a variable containing the last assigned value (or
equivalently, the next available value).

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
K

Karl E. Peterson

Jay Freedman said:
Or maintain a variable containing the last assigned value (or
equivalently, the next available value).

Yeah, if this is a frequently needed value, that'd definitely be more efficient.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top