The Add attribute function can be used to append a new item to a list.
Syntax | |||||
Add(Value, [Exclusive]) | |||||
Return value | |||||
Type |
Description | ||||
Long |
The index of the new item or -1 | ||||
Parameter | |||||
Required |
Value |
Variant |
ByVal |
The element to be inserted to the list | |
Optional |
Exclusive |
Boolean |
ByVal |
Default-Value False | |
Example:
Dim Colors() As String
Colors.Add("red")
Colors.Add("blue")
Colors.Add("green")
The Colors list now contains the values red, blue, green.
Dim Colors() As String
Colors.Add({"red", "blue", "green"})
Colors.Add("brown")
Colors.Add({"black", "gray", "pink"})
The Colors list now contains the values red, blue,green, brown, black, gray, pink.
Colors.Add({NoValue, NoValue, "red", "blue", "green"})
MsgBox(Colors(2))
The output shows red.