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