- VB,VBA
-
2016-03-31
Dictionaryクラスはハッシュテーブルのように使えるクラスです。
Collectionクラスも同じように使えるのですが、Dictionaryクラスはキーが存在するかどうかをチェックするメソッドがあることがポイントです。
Dim dict As Object Set dict = CreateObject("Scripting.Dictionary")
キーが存在しないことを確かめてからデータを追加します。
If dict.Exists("いちご") <> True Then dict.Add "いちご", "いちご" End If
ループして全ての値を取り出します。
For Each vntItem In dict.Items MsgBox vntItem Next vntItem
