VBA类:集合。项成员是集合。如何检索子集合项元素

VBA类:集合。项成员是集合。如何检索子集合项元素,vba,class,collections,Vba,Class,Collections,我有这个模板数据 文件头((string1、string2…) 组1标头(字符串1、字符串2…) 第1组/第1行(第1列、第2列…) 第1组/第2行(第1列、第2列…) 组2标头(字符串1、字符串2…) 第2组/第1列(第1列、第2列…) 第2组/第2行(第1列、第2列…) 注:属于组标题和组行的数据类型不同,即使它们位于同一“列”(原始数据来自文本文件) 我创建了我的主类(填充集合)和数据类(填充项:cData\U提名),所有东西都可以独立工作,但我需要创建: -1个文件集合(我有多个文件)存

我有这个模板数据

文件头((string1、string2…) 组1标头(字符串1、字符串2…) 第1组/第1行(第1列、第2列…) 第1组/第2行(第1列、第2列…) 组2标头(字符串1、字符串2…) 第2组/第1列(第1列、第2列…) 第2组/第2行(第1列、第2列…)

注:属于组标题和组行的数据类型不同,即使它们位于同一“列”(原始数据来自文本文件)

我创建了我的主类(填充集合)和数据类(填充项:cData\U提名),所有东西都可以独立工作,但我需要创建:

-1个文件集合(我有多个文件)存储 --字段(文件头)和 --x子集合(组)wich商店 ---字段(组标题) ---x子集合哪个存储 ----字段(行数据)

在第170行的以下代码中。oDpo是组集合,每个数据都存储在具有属性Let(..)的集合上。 一切似乎都在商店里

Public Function NomCreate(m_sFilepath As String, m_objDataList() As String, m_clDpo As Collection) As cData_Nomination

10        On Error GoTo Err_Handler
          Dim Functions As New cFunctions
          Dim objResult As cData_Nomination
          Dim objDate() As String



      'Note : Init Var(s) /Object(s)
      '----------------------------

20        Set objResult = New cData_Nomination

30        With objResult
40            .FileName = Functions.String_NZ(m_sFilepath)
50            .DataSource = Functions.String_NZ(m_objDataList(1))
60            .DelRes = Functions.String_NZ(m_objDataList(2))
70            .DateTime = Functions.Date_NZ(m_objDataList(4) & " " & m_objDataList(5) & ":00")
80            objDate = Split(Replace(m_objDataList(6), " - ", "-"), "-")
90            .DateTimeRange_Start = Functions.Date_NZ(objDate(0))
100           .DateTimeRange_End = Functions.Date_NZ(objDate(1))
110           .Sender = Functions.String_NZ(m_objDataList(7))
120           .Receiver = Functions.String_NZ(m_objDataList(8))
130           .GasPointName = Functions.String_NZ(m_objDataList(9))
140           .GasPointNameExternal = Functions.String_NZ(m_objDataList(10))
150           .Description = Functions.String_NZ(m_objDataList(11))
160           .DataType = Functions.String_NZ(m_objDataList(12))
170           .oDpo = Dpo
180       End With

Err_Exit:
          'Note : Return Function value
190       Set NomCreate = objResult
          'Note : Delete object
200       Set objResult = Nothing
          'Note : Exit
210       Exit Function

Err_Handler:
          'Note : Exit Function
220       GoTo Err_Exit
当我试图读取数据时遇到问题,我无法通过属性Get访问collection.oDo(请参阅以下代码)

如何将集合传递给现有项集合(我可能错了),如何从主集合检索子集合项

我希望这是清楚的

提前感谢

课程cNum(家长摘录)

类cDop(父级的子级)

类cQty(子类)

常规模块

Sub myModule()

    Dim i As Long
    Dim j As Long
    Dim k As Long
    Dim cNum As cNum
    Dim cDpo As cDpo
    Dim cQty As cQty
    Dim oNum As Collection
    Dim oDpo As Collection
    Dim oQty As Collection

    Set oNum = New Collection
    For i = 1 To 3
        Set cNum = New cNum
        cNum.FileName = "File " & i

        Set oDpo = New Collection
        For j = 1 To 3
            Set cDpo = New cDpo
            cDpo.Qty = "Qty" & i & j
            cDpo.Delivery = "Delivery " & i & j

            Set oQty = New Collection

            For k = 1 To 3
                Set cQty = New cQty
                cQty.Statut = "OK_" & i & "-" & j & "-" & k
                oQty.Add cQty                
            Next k

            Set cDpo.QtyAdd = oQty        

            oDpo.Add cDpo

        Next j

        Set cNum.DpoAdd = oDpo
        oNum.Add cNum

    Next i

    'Set oDpo = Nothing
    '

    For Each cNum In oNum
        Debug.Print ""
        Debug.Print "---------FILE ----------------"
        Debug.Print ""
        Debug.Print "-[NUM] " & cNum.FileName & " | " & cNum.Info
        Set oDpo = cNum.Dpo
        For Each cDpo In oDpo
            Debug.Print "--[DPO] " & cDpo.Counterpart & " | " & cDpo.Delivery

            Set oQty = cDpo.Qty
            For Each cQty In oQty
                Debug.Print "---[QTY] " & cQty.Quantity & " | " & cQty.Statut
            Next
        Next

    Next

End Sub
Private m_sFileName As String
Private oDpo As Collection

Private Sub Class_Initialize()
  Set oDpo = New Collection
End Sub

Public Property Get FileName() As String
    FileName = m_sFileName    
End Property

Public Property Let FileName(ByVal sFileName As String)
    m_sFileName = sFileName    
End Property

Public Property Get Dpo() As Collection
    Set Dpo = oDpo    
End Property

Public Property Set DpoAdd(DpoCollection As Collection)
    Dim DpoItem    
    For Each DpoItem In DpoCollection    
        oDpo.Add DpoItem        
    Next    
End Property
Private m_sDelivery As String
Private oQty As Collection

Private Sub Class_Initialize()
  Set oQty = New Collection
End Sub

Public Property Get Delivery() As String
    Delivery = m_sDelivery
End Property

Public Property Let Delivery(ByVal sDelivery As String)
    m_sDelivery = sDelivery
End Property


Public Property Get Qty() As Collection
    Set Qty = oQty
End Property

Public Property Set QtyAdd(QtyCollection As Collection)
    Dim QtyItem    
    For Each QtyItem In QtyCollection
        oQty.Add QtyItem
    Next
End Property
Private m_sStatus As String

Public Property Get Status() As String
    Status = m_sStatus
End Property

Public Property Let Status(ByVal sStatus As String)
    m_sStatus = sStatus
End Property
Sub myModule()

    Dim i As Long
    Dim j As Long
    Dim k As Long
    Dim cNum As cNum
    Dim cDpo As cDpo
    Dim cQty As cQty
    Dim oNum As Collection
    Dim oDpo As Collection
    Dim oQty As Collection

    Set oNum = New Collection
    For i = 1 To 3
        Set cNum = New cNum
        cNum.FileName = "File " & i

        Set oDpo = New Collection
        For j = 1 To 3
            Set cDpo = New cDpo
            cDpo.Qty = "Qty" & i & j
            cDpo.Delivery = "Delivery " & i & j

            Set oQty = New Collection

            For k = 1 To 3
                Set cQty = New cQty
                cQty.Statut = "OK_" & i & "-" & j & "-" & k
                oQty.Add cQty                
            Next k

            Set cDpo.QtyAdd = oQty        

            oDpo.Add cDpo

        Next j

        Set cNum.DpoAdd = oDpo
        oNum.Add cNum

    Next i

    'Set oDpo = Nothing
    '

    For Each cNum In oNum
        Debug.Print ""
        Debug.Print "---------FILE ----------------"
        Debug.Print ""
        Debug.Print "-[NUM] " & cNum.FileName & " | " & cNum.Info
        Set oDpo = cNum.Dpo
        For Each cDpo In oDpo
            Debug.Print "--[DPO] " & cDpo.Counterpart & " | " & cDpo.Delivery

            Set oQty = cDpo.Qty
            For Each cQty In oQty
                Debug.Print "---[QTY] " & cQty.Quantity & " | " & cQty.Statut
            Next
        Next

    Next

End Sub