Skip to content

Instantly share code, notes, and snippets.

@MirzaLeka
Created September 19, 2023 19:01
Show Gist options
  • Save MirzaLeka/6dedcf3c3590c856ffaa2b824e58617a to your computer and use it in GitHub Desktop.
Save MirzaLeka/6dedcf3c3590c856ffaa2b824e58617a to your computer and use it in GitHub Desktop.
VBA array of objects

Array of Objects in VBA

Sub Button1_Click()

    Dim arr() As Object
    Dim data As Object
    
    ' Create the object
    Set data = CreateObject("Scripting.Dictionary")
    data.Add "type", "C0"
    data.Add "amount", 100
    
    ' Resize the array and assign the object to the first element
    ReDim arr(0)
    Set arr(0) = data
    
    ' Accessing the object in the array
    MsgBox "Type: " & arr(0)("type") & ", Amount: " & arr(0)("amount")

End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment