Método Item

Obtém ou define o elemento no índice especificado do Objeto ArrayList.

Sintaxe

Object.Item(Index)

Argumentos:

  • Object: Obrigatório. Sempre o nome do objeto ArrayList.

  • Index: Obrigatório. O índice baseado em zero do elemento a ser obtido.

Retorna

Retorna o elemento que está no Índice.

Comentários

O exemplo a seguir ilustra o uso do método Item.

Exemplo 1:

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

'Add Elements to the end of ArrayList Object
Dim Index
Index = Obj.Add(10)
Index = Obj.Add(40)
Index = Obj.Add(20)
'Output: Obj contains 10, 40, 20

'Gets the Element from the ArrayList Object
Dim Element
Index = 2
If Index < Obj.Count() Then
Element = Obj.Item(Index)
'Output: 20
End If

'Set the Element in the ArrayList Object
Index = 1
If Index < Obj.Count() Then
Obj.Item(Index) = 15
End If
'Output: Obj contains 10, 15, 20