Metodo Add

Aggiunge un elemento alla fine dell'oggetto ArrayList.

Sintassi

Object.Add (Element)

Argomenti:

  • Object: obbligatorio. Sempre il nome dell'oggetto ArrayList.

  • Element: obbligatorio. Elemento da aggiungere alla fine dell'oggetto ArrayList

Valore restituito

L'indice ArrayList a cui è stato aggiunto l'elemento

Note

Nell'esempio seguente viene illustrato l'uso del metodo Add.

Esempio 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

Esempio 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"