Count 屬性

會傳回 Long (長整數) 包含集合或 Dictionary 物件中的專案數。 唯讀。

語法

物件計數

物件一律是 [套用至] 清單中其中一個專案的名稱。

註解

下列程式碼說明 Count 屬性的使用方式。

Dim a, d, i             'Create some variables
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens"     'Add some keys and items.
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
a = d.Keys              'Get the keys
For i = 0 To d.Count -1 'Iterate the array
    Print a(i)          'Print key
Next
...

另請參閱

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應