Método Add

Adiciona um elemento ao final do Objeto ArrayList.

Sintaxe

Object.Add (Element)

Argumentos:

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

  • Element: Obrigatório. O Elemento a ser adicionado ao final da ArrayList

Retorna

O índice da ArrayList na qual o Elemento foi adicionado

Comentários

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

Exemplo 1:

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

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

Exemplo 2:

'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("Banana")
'Output: 0
Index = Obj.Add("Apple")
'Output: 1
Index = Obj.Add("Grapes")
'Output: 2
'Output: Obj contains "Banana", "Apple", "Grapes"