Существует также способ использования словаря, возможно, избыточного, но он дает возможность добавлять новые пары данных на лету.
Класс как таковой
Public Extract As Scripting.Dictionary
Private Sub Class_Initialize()
Set Extract = New Scripting.Dictionary
AddDefault "Name", "1"
AddDefault "ID", "2"
AddDefault "Address", "3"
End Sub
Private Sub Class_Terminate()
Set Extract = Nothing
End Sub
Public Function AddToExisting(strKey As String, _
strContentsKey As String, _
strContentsValue As String)
Extract(strKey).Add strContentsKey, strContentsValue
End Function
Private Function AddDefault(strKey As String, strValue As String)
Extract.Add strKey, CreateKeyValuePair(strKey & " Tag", strValue)
End Function
Private Function CreateKeyValuePair( _
strKey As String, _
strValue As String) As Scripting.Dictionary
Dim dicTemp As New Scripting.Dictionary
With dicTemp
.Add "Tag", strKey
.Add "Value", strValue
End With
Set CreateKeyValuePair = dicTemp
End Function
Затем используется кактак
Sub testComplex()
Dim c As New clsComplex
Debug.Print c.Extract("Name")("Tag")
Debug.Print c.Extract("Name")("Value")
c.AddToExisting "ID", "Date of Value", CStr(Date)
c.AddToExisting "ID", "Date of Value Check", CStr(Date + 20)
Debug.Print c.Extract("ID")("Tag")
Debug.Print c.Extract("ID")("Value")
Debug.Print c.Extract("ID")("Date of Value")
Debug.Print c.Extract("ID")("Date of Value Check")
c.AddToExisting "Address", "Address Proof", "Utility Bill"
Debug.Print c.Extract("Address")("Tag")
Debug.Print c.Extract("Address")("Value")
Debug.Print c.Extract("Address")("Address Proof")
Set c = Nothing
End Sub