수색…


사전 작성 및 사전에 항목 추가

Dim oDic
Set oDic = CreateObject("Scripting.Dictionary")
oDic.Add "US", "United States of America"
oDic.Add "UK", "United Kingdom"

사전에 키가 있는지 확인하십시오.

If oDic.Exists("US") Then
    msgbox "The Key US Exist. The value is " + oDic("US")
Else
    msgbox "Key Does not exist."
End If 

사전에서 항목 제거

If oDic.Exists("UK") Then
    oDic.remove("UK")
End If

사전에있는 모든 항목 반복

set oDic = CreateObject("Scripting.Dictionary")
oDic.add "USA", "United States of America"
oDic.add "UK", "United Kingdom"
oDic.add "CAN", "Canada"

For Each obj in oDic.Items
    Msgbox obj
Next
Set oDic = Nothing

* 출력 :

아메리카 합중국

영국

캐나다

사전에있는 모든 키 반복

set oDic = CreateObject("Scripting.Dictionary")
oDic.add "USA", "United States of America"
oDic.add "UK", "United Kingdom"
oDic.add "CAN", "Canada"

For Each obj in oDic.keys
    Msgbox "Key: " & obj & " Value: " & oDic(obj)
Next
Set oDic = Nothing

사전에서 키 / 키 삭제

set oDic = CreateObject("Scripting.Dictionary")
oDic.add "USA", "United States of America"
oDic.add "UK", "United Kingdom"
oDic.add "CAN", "Canada"

' Delete only if Key exists
If oDic.Exists("UK") Then
    oDic.Remove "UK"
End If    

' Delete all keys from Dictionary
oDic.removeAll 

Set oDic = Nothing


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow