0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

scripting.dictionaryについて

Posted at

scripting.dictionaryについて

VBAで用いられるオブジェクト

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

' 値の追加
dict.Add "名前", "太郎"
dict.Add "年齢", 30

' 値の取得
MsgBox dict("名前") ' 太郎 と表示される

' 値の変更
dict("年齢") = 31

' キーの存在チェック
If dict.Exists("名前") Then
MsgBox "名前があります"
End If

' キーの削除
dict.Remove "年齢"

' 全件ループ(キーと値を出力)
Dim key As Variant
For Each key In dict.Keys
Debug.Print key & ":" & dict(key)
Next

連想配列としてキーと値のペアを扱うオブジェクト
Pythonでいうdict、JavaScriptでいう、{}。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?