property Items.Count as Long
Retrieves the number of items.

TypeDescription
Long A long expression that indicates the items count.

Use the Count property to count the items into the Items collection. Use the VisibleCount property to get the count of visible items. Use the FirstVisibleItem property to get the index of the first visible item. Use the NextVisibleItem property to get the index of the next visible item. Use the SortOrder property to sort a column. Use the ItemPosition property to specify the position of the item.

The following VB sample displays all items in the list:

With List1.Items
    For i = 0 To .Count - 1
        Debug.Print .Caption(i, 0)
    Next
End With

The following C++ sample displays all items in the list:

CItems items = m_list.GetItems();
for ( long i = 0; i < items.GetCount(); i++ )
{
	CString strCaption = V2S( &items.GetCaption( i, COleVariant( long(0) ) ) );
	OutputDebugString( strCaption );
}

where the V2S function converts a VARIANT expression to a string expression:

static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return szDefault;

		COleVariant vt;
		vt.ChangeType( VT_BSTR, pv );
		return V_BSTR( &vt );
	}
	return szDefault;
}

The following VB.NET sample displays all items in the list:

With AxList1.Items
    Dim i As Integer
    For i = 0 To .Count - 1
        Debug.WriteLine(.Caption(i, 0))
    Next
End With

The following C# sample displays all items in the list:

for (int i = 0; i < axList1.Items.Count; i++)
{
	object cell = axList1.Items.get_Caption(i, 0);
	System.Diagnostics.Debug.WriteLine(cell != null ? cell.ToString() : "");
}

The following VFP sample displays all items in the list:

With thisform.List1.Items
    For i = 0 To .Count - 1
        wait window nowait .Caption(i, 0)
    Next
EndWith