Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))

Collection.Count Property

Class

Microsoft.VisualBasic.Collection

Syntax

Dim result As Integer = objectVariable.Count

objectVariable (required; Collection)

The instance of a Collection for which items are to be counted

Description

The Count property returns the number of items currently contained in a collection.

Usage at a Glance

Collections are 1-based; this differs from arrays, which are 0-based. Collection items range from 1 to the value returned by the Count property.

Example

For counter = 1 To someCollection.Count oneItem = someCollection.Item(counter) ...more code here... Next counter

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.Item Property, Collection.Remove Method

Категории