ArrayList: AddRange |
Adds the items from a collection to the list.
Public Sub AddRange( ByRef Source As Variant )
The collection can be a VBA.Collection, ICollection object, or an Array.
The elements are added to the end of the list in the same order as a For..Each loop produces.
If the number of elements to be added is more than the available capacity in the ArrayList, then the capacity is increased to accommodate the collection of elements.
Exception Type | Condition |
---|---|
ArgumentNullException | c is an uninitialized array. -or- c is Nothing. |
NotSupportedException | The ArrayList is read-only -or- The ArrayList is fixed size. |
InvalidCastException | c is not a VBA.Collection, ICollection object, or an Array. |
The following example demonstrates using the AddRange method to add a collection of items.
Private Sub Main() Dim List As New ArrayList Dim Words() As String Words = NewStrings("The", "fox", "jumps", "over", "the", "dog") List.AddRange Words PrintValues List End Sub Private Sub PrintValues(ByVal Source As IEnumerable) Dim Value As Variant Console.WriteValue vbTab For Each Value In Source Debug.Print CorString.Format("{0} ", Value); Next Value End Sub ' This example produces the following output. ' ' The fox jumps over the dog