
Originally Posted by
muck
Using AutoCAD 2000+ VBA
What the best method for adding two arrays and creating a 3rd array
without looping and using redim. Is there a easy way to do it.
Say adding revarray() to array1().
any sample code?
thank you,
Try collection instead of array
Here is a quick example
Code:
Option Explicit
Sub AppendDemo()
Dim ar1(5, 1) As Variant
Dim ar2(5) As Variant
Dim col As New Collection
Dim i As Integer, c As Integer
c = 0
For i = 0 To 5
ar1(i, 0) = c + 1
ar1(i, 1) = c + 2
ar2(i) = c + 3
c = c + 3
Next
Dim tmp(2) As Variant
For i = 0 To 5
tmp(0) = ar1(i, 0): tmp(1) = ar1(i, 1): tmp(2) = ar2(i)
col.Add tmp
Next
ReDim ap(UBound(ar1, 1), UBound(ar1, 2) + 1) As Variant
For i = 1 To col.Count
ap(i - 1, 0) = col.Item(i)(0)
ap(i - 1, 1) = col.Item(i)(1)
ap(i - 1, 2) = col.Item(i)(2)
Next
End Sub
Hth
~'J'~
Bookmarks