Collection.Item Property


Collection.Item Property

Class

Microsoft.VisualBasic.Collection

Syntax

     objectVariable.Item(index) 


objectVariable (required; Collection)

The instance of a Collection from which an item is to be retrieved


index (required; Integer or String)

Either the 1-based ordinal position (Integer) or the unique key (String) of an item in the collection

Description

The Item property retrieves an item from a collection based on its position or its unique key.

Usage at a Glance

  • The Contains method of the Collection class can tell you whether the collection includes an item with a specific key.

  • The Item property is the default member of the Collection object; the "Item" member name can be omitted when retrieving items from a collection. The following two lines are functionally identical:

         typicalItem = ordinaryCollection.Item(6)     typicalItem = ordinaryCollection(6) 

Version Differences

Visual Basic 2005 adds support for generics to several collection-style classes. Generics are discussed in Chapter 10.

See Also

Collection Class, Collection.Add Method, Collection.Count Property, Collection.Remove Method




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net