Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Array of Arrays (VB6)

    I have been trying to ReDim an array that is contained within an array, and was getting myself wrapped around the post until I came up with the following approach that seems to work well. And just out of interest, I placed my array of arrays within yet another array and all seems well. Two questions remain in my mind:

    1. <LI>Am I not violating the requirement that Arrays of Arrays must be of the variant data type? I thought that this would apply to all elements.
      <LI>Is there a better approach?
    <pre>
    Dim ArrayArray() As Variant
    ReDim ArrayArray(1)

    Dim StringArray() As String
    Dim DateArray() As Date

    ReDim StringArray(2, 3)
    ReDim DateArray(4, 5)

    ArrayArray(0) = StringArray
    ArrayArray(1) = DateArray

    ArrayArray(0)(1, 2) = "This is (1,2)"
    Dim AAA() As Variant
    ReDim AAA(1)
    AAA(1) = ArrayArray

    </pre>

    Regards
    Don

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Array of Arrays (VB6)

    1) No. You declare ArrayArray as a Variant, but you can assign any type of data to the individual elements.
    2) What are you going to do with such an array of arrays?

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Array of Arrays (VB6)

    I will be copying an unknown number of files from one set of directories to another set of directories. There may be files that are targeted for overwriting which are in-use. The targeted files may also not require updating, having the same timestamp.
    The attached file contains a module which I tailored from something I downloaded from the Lounge. This module requires arrays as arguments. my intent is to call it iteratively and populate an array that I can interrogate iteratively to determine which files can be copied.
    I will also be able to log which ones have been copied, and after a defined wait-time retry those that were unsuccessful on possibility that the user has released them.
    Regards
    Don

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Array of Arrays (VB6)

    Collections or the Scripting.Dictionary object (you can do a search for it in this forum) would be other ways to store the data. Personally, I would probably store them in a table (or tables) in an Access database, because
    a) a table is (more or less) permanent, the data will be available even if the program crashes.
    [img]/forums/images/smilies/cool.gif[/img] data in a table can be sorted, searched, deleted and inserted easily.

  5. #5
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Array of Arrays (VB6)

    Thanks for the feedback Hans.
    Regards
    Don

  6. #6
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Array of Arrays (VB6)

    By the way Hans; is it possible that you would ever be associated with a program that crashed? <img src=/S/salute.gif border=0 alt=salute width=15 height=20>
    <hr>a) a table is (more or less) permanent, the data will be available even if the program crashes.<hr>
    Regards
    Don

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Array of Arrays (VB6)

    If you paid me $1 for each time I made a program crash, I'd be a rich man! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Posting Permissions

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