ArrayList: Add |
Adds a new item to the end of the list.
Public Function Add( ByRef Value As Variant ) As Long
Exception Type | Condition |
---|---|
NotSupportedException | The ArrayList is Read-Only - or - The ArrayList is Fixed-Size. |
Private Sub Main() Dim list As New ArrayList add several elements to the ArrayList list.Add "Humpty" list.Add "Dumpty" list.Add "sat" list.Add "on" list.Add "a" list.Add "wall." Display the contents of the ArrayList PrintValues list Wait for user to press return key Console.ReadLine End SubPrivate Sub PrintValues(ByVal en As IEnumerable) Const Space As String = " " Dim value As Variant Iterate over the list For Each value In en Write each value onto the same line Console.WriteValue value Console.WriteValue Space Next valueEnd Sub This code produces the following output. Humpty Dumpty sat on a wall.The items are added to the list, then a For..Each statement is usedto iterate over the list, displaying the name in the Console window.
Class ArrayList Overview ArrayList Properties ArrayList Methods AddRange