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 / Outlook / Programming VBA / April 2005

Tip: Looking for answers? Try searching our database.

Setting dimensions for Dynamic Arrays

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
devlei - 26 Apr 2005 05:53 GMT
I use dynamic arrays to hold data from certain Calendar items based on
specified criteria .

Before extracting the data I don't know how many items will meet the
criteria so I do one iteration through all the items to count, then
Redim the array, then iterate a second time to fill the array.  But
with 900 items in the folder using the OOM, this takes too long.

Is there an easier way to Redim the array without iterating through
twice?

With thanks
Ken Slovak - [MVP - Outlook] - 26 Apr 2005 14:36 GMT
Set a Restriction on the Items collection of the folder that filters on your
valid data condition and that will return a filtered Items collection. Use
the Count property to see how many items you need to set up for your array.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

>I use dynamic arrays to hold data from certain Calendar items based on
> specified criteria .
[quoted text clipped - 8 lines]
>
> With thanks
devlei - 26 Apr 2005 15:13 GMT
Many Thanks Ken
Michael Bauer - 26 Apr 2005 15:44 GMT
Oh no, that´s to easy :-)

Signature

Viele Grüße
Michael Bauer - MVP Outlook

> Set a Restriction on the Items collection of the folder that filters on your
> valid data condition and that will return a filtered Items collection. Use
> the Count property to see how many items you need to set up for your array.
Ken Slovak - [MVP - Outlook] - 27 Apr 2005 14:52 GMT
Easy is good sometimes, no? :)

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Oh no, that´s to easy :-)
Michael Bauer - 27 Apr 2005 18:24 GMT
I wish it would be! Currently I´ve to make my first steps with mambo
(CMS) and feel like some people here: Nothing works and I don´t know
where to start...

Signature

Viele Grüße
Michael Bauer - MVP Outlook

> Easy is good sometimes, no? :)
>
> > Oh no, that´s to easy :-)
Michael Bauer - 26 Apr 2005 15:28 GMT
Hi,

in this case I´d use an approximately value for the dimension. The
sample I´ve just hacked without testing, please check with a little
value for ARRAY_BUFFER, e.g. 1 and 2.

Private Const ARRAY_BUFFER As Long = 1000
Private m_lPos As Long
Private m_lCnt As Long
Private m_aData() As Variant

Private Sub InitArray()
 m_lPos = -1
 m_lCnt = ARRAY_BUFFER
 ReDim m_aData(ARRAY_BUFFER - 1)
End Sub

Private Sub AddElement(v As Variant)
 m_lPos = m_lPos + 1
 m_aData(m_lPos) = v
 If m_lPos = (m_lCnt - 1) Then
   m_lCnt = m_lCnt + ARRAY_BUFFER
   ReDim Preserve m_aData(m_lCnt - 1)
 End If
End Sub

Private Sub TrimArray()
 Select Case m_lPos
 Case Is < 0
   m_lCnt = 1
   ReDim m_aData(0)
 Case Is < (m_lCnt - 1)
   m_lCnt = m_lPos + 1
   ReDim Preserve m_aData(m_lPos)
 End Select
End Sub

Public Sub TestArray()
 InitArray
 AddElement "1"
 AddElement "2"
 AddElement "3"
 TrimArray
End Sub

Signature

Viele Grüße
Michael Bauer - MVP Outlook

> I use dynamic arrays to hold data from certain Calendar items based on
> specified criteria .
[quoted text clipped - 8 lines]
>
> With thanks
 
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.