Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2007

Tip: Looking for answers? Try searching our database.

question about arrays

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rick Charnes - 31 Aug 2007 16:38 GMT
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.
Karl E. Peterson - 31 Aug 2007 18:22 GMT
> 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.
Signature

.NET: It's About Trust!
http://vfred.mvps.org

Jay Freedman - 31 Aug 2007 19:19 GMT
>> 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
[quoted text clipped - 4 lines]
>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        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
Karl E. Peterson - 31 Aug 2007 20:14 GMT
>>> 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
[quoted text clipped - 7 lines]
> 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.
Signature

.NET: It's About Trust!
http://vfred.mvps.org


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.