Collections 
Author Message
 Collections

Hi,
Can anyone give mea good explanation on collections: What are they and when
and how do i use them ?

Thanks alot for your help!

Robert Goen



Wed, 03 Jul 2002 03:00:00 GMT  
 Collections
Robert,

Collections are containers - like a drawer in a filing cabinet - only, in
this example, they are not restricted to holding only file folders.

In VB6, the collection object allows you to construct arbitrary collections
of items, be those items variables (of *any* type - even other collection
variables are acceptable - allowing one to create hierarchical collection
structures should an application require such a beastie), data recordsets,
or other objects - even UDTs are permitted.
These collection objects can then be passed to/from functions and
subroutines for processing, and VB provides a simple syntax for processing
all the items in a collection:
for each n in MyCollectionVariable
 ...do something with the item 'n' here...
next
Items may be arbitrarily ADDed to or REMOVEd from a collection at your
direction.
Individual items may be retrieved for processing either by  it's position
within the collection (from 1 to the MyCollectionVariable.Count limit -
collections always know hoe many items they contain) or by a (unique) key
string value specified for them when they were ADDed to the collection. As
in:
x = MyCollectionVariable.item(12) (where MyCollectionVariable.Count >=12)
or
x=MyCollectionVariable.item("MyItemID")

How are they used? Well, Windows and VB themselves use collections...there
is a FORMS collection which holds all the open FORM objects in the VB
runtime environment, and each FORM object has a CONTROLS collection that
holds all the controls loaded on that form... does that begin to show you
some ways that collections are used? There are myriad other uses for them -
be inventive. Have fun with them.

Oh, and before anyone else yells at you, posting the same message to so many
newsgroups at the same time is considered very bad manners (you are
"spamming" the newsgroups) - and that will provoke some folks' ire for such
an offense. It is not a good idea to make any sort of habit of it.


Quote:
> Hi,
> Can anyone give mea good explanation on collections: What are they and
when
> and how do i use them ?

> Thanks alot for your help!

> Robert Goen



Fri, 05 Jul 2002 03:00:00 GMT  
 Collections
Have you looked in the Help files?  If you have VB6, search for Collections in
Visual Basic in the MSDN Help.

John.............

Quote:

> Hi,
> Can anyone give mea good explanation on collections: What are they and when
> and how do i use them ?

> Thanks alot for your help!

> Robert Goen



Fri, 05 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Collections, Collections and More Collections

2. Document collections and AllForms collections

3. Creating a CDO collection from an Outlook collection

4. using collection of collections

5. Storing a collection in a collection

6. collection in collection

7. Migrating to System.Collections.IEnumerator from VB6.Collection

8. Persisting a Collection of a Collection

9. Collection of Collections?

10. Collections, swapping items in a collection

11. Collections of Collections..how?

12. collections of collections

 

 
Powered by phpBB® Forum Software