0
以下是用于读取每个字典中对象充当主字典中的项目(channel
)中的项数的代码。这是存在的给定的图像文件中被示出项目在字典中
Dim facebook As Object, instagram As Object, twitter As Object, name As String, channel As Object, _
type_name As String, Key As Variant, values(5) As Integer, i As Integer, j As Integer
Set facebook = CreateObject("Scripting.Dictionary")
For i = 0 To 4
values(i) = Cells(i + 1, 1)
Next i
With facebook
.Add "brand", values
.Add "post", 6
.Add "likes", 7
End With
Set instagram = CreateObject("Scripting.Dictionary")
With instagram
.Add "brand", 8
.Add "post", 9
.Add "likes", 10
End With
Set twitter = CreateObject("Scripting.Dictionary")
With twitter
.Add "brand", 11
.Add "post", 12
.Add "likes", 13
End With
Set channel = CreateObject("Scripting.Dictionary")
With channel
.Add "facebook", facebook
.Add "twitter", twitter
.Add "instagram", instagram
End With
For i = 0 To channel.count - 1
MsgBox channel.Keys(i) & " has " & channel(channel.Keys(i)).count & " keys."
Next i
错误:
如果我替换MsgBox channel.Keys(i) & " has " & channel(channel.Keys(i)).count & " keys."
与MsgBox channel.Keys(i) & " has " & channel.Items(i).count & " keys."
,然后也被给予同样的错误。