Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Collection Object Keys

Stephen Bullen wrote:

Hi Alan,
. . .
Is there
any generic reason to avoid Collections and use Dictionary Objects instead?



It's a matter of personal preference. I find Dictionaries to be generally
faster and more flexible than Collections, mainly because:
- It has an Exists property to quickly determine if an element exists
- You can easily change the keys
- It has an Items property to retrieve the entire set of items as an array
- It has a Keys property to retrieve the entire set of keys as an array

The biggest thing it can't do is insert items within the list, so it's no
good if you need a set that can be reordered. Using them also requires a
reference to the Microsoft Scripting Runtime, but I've not found that to be a
problem.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk

Thanks very much, Stephen; I haven't worked much with collections and
until now not at all with dictionaries, so this is quite helpful.

Two other differences I noted: The Dictionary Object seems to be 0-based
(at any rate, myArray = x.Keys seems to be a 0-based array
notwithstanding an Option Base 1 Statement); and the Dictionary Object
seems to be case sensitive while the Collection Object is not, which can
in fact be a helpful distinction--See the procedure in my contemporary
posting "To declare or not to declare".

Thanks again,
Alan Beban
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Label Options - Forms Object vs Control Box Object Awrex Excel Discussion (Misc queries) 3 July 17th 09 07:10 PM
Function unable to return Collection object Adrian[_7_] Excel Programming 1 July 12th 04 06:22 PM
CombBox - Object of What Collection? George Excel Programming 7 February 10th 04 12:01 AM
Range object to Array object conversion Myrna Larson[_2_] Excel Programming 1 August 1st 03 02:27 AM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


All times are GMT +1. The time now is 03:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"