Add-Methode

Fügt ein Element am Ende des ArrayList-Objekts hinzu.

Syntax

Object.Add (Element)

Argumente:

  • Object: Erforderlich. Immer der Name eines ArrayList-Objekts.

  • Element: Erforderlich. Das Element, das am Ende von ArrayList hinzugefügt werden soll

Rückgabe

Der ArrayList-Index, dem das Element hinzugefügt wurde

Anmerkungen

Das folgende Beispiel veranschaulicht die Verwendung der Add-Methode.

Beispiel 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

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