返回 ArrayList 对象中某值首次出现的基于零的索引。
语法
Object.IndexOf(Element,StartIndex)
参数:
Object:必需。始终为 ArrayList 对象的名称。
Element:必需。要在 ArrayList 对象中查找的对象。
StartIndex:必需。搜索的基于零的起始索引
返回
ArrayList 中元素范围内值首次出现的基于零的索引(可从 StartIndex 扩展到最后一个元素,如果找到);否则,返回 -1
注释
以下示例说明了 IndexOf 方法的用法。
示例 1:
'Create ArrayList Object
Dim Obj
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)
'Get the Index of the Element
Index = Obj.IndexOf(40, 0)
'Output: 1
Index = Obj.IndexOf(50, 0)
'Output: -1