+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Super Member
    Using
    not specified
    Join Date
    Feb 2006
    Posts
    527

    Default Adding Two Arrays?

    Registered forum members do not see this ad.

    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,
    Last edited by muck; 2nd Feb 2007 at 04:28 pm. Reason: More info

  2. #2
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    What the best method for adding two arrays and creating a 3rd array
    without looping and using redim.
    May be without VBA and PC?

    It's impossible. If you need this operation, you should one time to write function like:

    Code:
    Private Function Add_Array_To_Array (Arr1 (), Arr2() As Variant) As Variant
    
    ........... Function body .......
    
    End Function
    And use it long time in all your routines.

    I think something like it is possible to find in Internet.

  3. #3
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,588

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by muck View Post
    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'~

Similar Threads

  1. Help Adding Hatches!!!!!
    By alessandro754 in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 26th Nov 2006, 06:25 pm
  2. polyline(arrays series problem)
    By stary7 in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 21st Sep 2006, 10:23 pm
  3. Basic VBA - arrays of points to a SketchLine(s) function?
    By dave_b in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 25th Jun 2006, 11:44 pm
  4. Adding ID points
    By daiharv in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 28th Dec 2005, 03:03 pm
  5. Adding a Button!
    By xoom2 in forum AutoCAD Drawing Management & Output
    Replies: 12
    Last Post: 25th May 2004, 01:52 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts