Dictionaryオブジェクトの作成

Dim dict As Object

Set dict = CreateObject("Scripting.Dictionary")

値の追加

dict.Add "キー", "値"

値の取得

MsgBox dict("キー")

値の変更

dict("キー") = "新しい値"

キーの存在チェック

If dict.Exists("キー") Then
 'キーが存在する場合の処理 
Else
 'キーが存在しない場合の処理 
End If

値の削除

dict.Remove "キー"

Dictionaryの要素数の取得

Dim count As Long
count = dict.Count
 

Dictionaryの全要素の削除

dict.RemoveAll

Dictionaryの反復処理

Dim key As Variant
For Each key In dict.Keys
MsgBox dict(key)
Next key