VBA Dictionaryの件数を取得する

環境
Windows 10 Home
Excel 2013

構文
ディクショナリ名.Count
countでdictionaryの要素の件数を取得しています。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Sub testark()
Dim city As Object
Set city = CreateObject("Scripting.Dictionary")
city.Add "ta", "東京"
city.Add "tb", "大阪"
city.Add "tc", "福岡"
Debug.Print city.Count
End Sub
Sub testark() Dim city As Object Set city = CreateObject("Scripting.Dictionary") city.Add "ta", "東京" city.Add "tb", "大阪" city.Add "tc", "福岡" Debug.Print city.Count End Sub
Sub testark()

    Dim city As Object
    Set city = CreateObject("Scripting.Dictionary")

    city.Add "ta", "東京"
    city.Add "tb", "大阪"
    city.Add "tc", "福岡"
    
    Debug.Print city.Count

End Sub

実行結果
3

VBScript

Posted by arkgame