Platform SDK: CDO 1.2.1

Count Property (Fields Collection)

The Count property returns the number of Field objects in the collection. Read-only.

Syntax

objFieldsColl.Count

Data Type

Long

Example

This code fragment maintains a global variable as an index into the small collection, and uses the Count property to check its validity:

' from Fields_NextItem 
' iFieldsCollIndex is an integer used as an index 
'   check for empty collection ... 
'   check index upper bound 
    If iFieldsCollIndex >= objFieldsColl.Count Then 
        iFieldsCollIndex = objFieldsColl.Count 
        MsgBox "Already at end of Fields collection" 
        Exit Function 
    End If 
    ' index is < count; can be incremented by 1 
    iFieldsCollIndex = iFieldsCollIndex + 1 
    Set objOneField = objFieldsColl.Item(iFieldsCollIndex) 
    If objOneField Is Nothing Then 
        MsgBox "Error, cannot get this Field object" 
        Exit Function 
    Else 
        MsgBox "Selected field # " & iFieldsCollIndex 
    End If