Count 方法

取得實際包含於 ArrayList 物件中的元素數目。

語法

Object.Count()

引數 - Object必要。一律是 ArrayList 物件的名稱。

傳回

實際包含於 ArrayList 物件中的元素數目

備註

下列範例說明 Count 方法的用法。

範例 1:

'Create ArrayList Object
Dim Obj
Dim Cnt
Set Obj = CreateObject("System.Collections.ArrayList")

'Add Elements to the end of the ArrayList Object
Dim Index
Index = Obj.Add(10)
Index = Obj.Add(40)
Index = Obj.Add(20)
'Gets the number of elements actually contained in the ArrayList object.
Cnt = Obj.Count()  
'Output: 3