Results 1 to 3 of 3

Thread: [RESOLVED] A Scripting.Dictionary of arrays of collections

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    223

    Resolved [RESOLVED] A Scripting.Dictionary of arrays of collections

    I would like to have a scripting.dictionary.


    Code:
        Dim sqlArray As Scripting.Dictionary
        Set sqlArray = New Scripting.Dictionary

    Each element of the scripting dictionary is an array of 2 Collections.

    Code:
                Dim tableName as string
                tableName = "foo"
    
                Dim ar(0 To 1) As Collection
                Set ar(0) = New Collection
                Set ar(1) = New Collection
                sqlArray.Add tableName, ar
    Is there anything wrong with this code? Intellisense isn't working on it, and in my experience, if intellisense doesn't work with early binding, it usually means my code is wrong. This is the full routine:


    Code:
    Private Function createInsertsArray() As Scripting.Dictionary
        Dim sqlArray As Scripting.Dictionary
        Set sqlArray = New Scripting.Dictionary
    
        Dim ptr As Range, table As String
        Set ptr = Worksheets("fields").Range("A1")
    
        Do While ptr.Value <> vbNullString
            table = accessTable(ptr.Value)
    
            If Not sqlArray.Exists(table) Then
                Dim ar(0 To 1) As Collection
                Set ar(0) = New Collection
                Set ar(1) = New Collection
                sqlArray.Add table, ar
            End If
    
            sqlArray(table)(0).Add ptr.Offset(0, 4).Value
            sqlArray(table)(1).Add ptr.Offset(0, 5).Value
            debug.Print sqlArray(table)(0).  <---- intellisense stops working
    
            Set ptr = ptr.Offset(1, 0)
        Loop
    
        Set createInsertsArray = sqlArray
    End Function
    I'm really confused. This should be simple:

    • sqlArray is a Scripting.Dictionary
    • sqlArray(table) is an array of 2 Collections
    • sqlArray(table)(0) is a Collection


    Therefore, when I type the last "." in sqlArray(table)(0). I expect Collection methods to appear, but they don't. My syntax is probably wrong. Can someone please help?

    Thanks!
    Last edited by caffeine; Jun 13th, 2015 at 03:56 PM.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width