2016-08-31 19 views
0

以下は、オブジェクトがメイン辞書の項目として機能するすべての辞書(channel)のキーの数を読み取るコードです。私は、その後も、それは同じエラーを与えている、MsgBox channel.Keys(i) & " has " & channel.Items(i).count & " keys."MsgBox channel.Keys(i) & " has " & channel(channel.Keys(i)).count & " keys."を交換した場合辞書の項目

Error

:発生している

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 

エラーは、指定した画像ファイルに示されています。

答えて

0

Dictionary.Keys()はプロパティではなく、関数であり、パラメータを受け入れません。常にすべてのキーを返します。の後にの後に必要なキーを選択する必要があります。

MsgBox channel.Keys()(i) & " has " & channel(channel.Keys()(i)).Count & " keys." 
関連する問題