- 方法
1.1 add方法
d.add(key,item)
Dim d as Object
Set d = CreateObject("Scripting.Dictionary")
d.add "a","苹果"
d.add "b","香蕉"
d.add "c","梨子"
'若key已经存在,那么将导致一个错误
1.2 Exits方法
d.Exits(key)
Dim d as Object
Set d = CreateObject("Scripting.Dictionary")
d.add "a","苹果"
d.add "b","香蕉"
d.add "c","梨子"
if d.Exits("c") then
msg="关键字已存在"
else
msg="关键字不存在"
end if
1.3 keys方法
d.keys
Dim d as Object,k
Set d = CreateObject("Scripting.Dictionary")
d.add "a","苹果"
d.add "b","香蕉"
d.add "c","梨子"
k=d.keys
[a1].Resize(d.count,1)=Application.Transpose(k)
1.4 Items方法
d.Items
Dim d as Object,t
Set d = CreateObject("Scripting.Dictionary")
d.add "a","苹果"
d.add "b","香蕉"
d.add "c","梨子"
t=d.Items
[a1].Resize(d.count,1)=Application.Transpose(t)
1.5 Remove方法
d.Remove("a")
Dim d as Object
Set d = CreateObject("Scripting.Dictionary")
d.add "a","苹果"
d.add "b","香蕉"
d.add "c","梨子"``
d.Remove("b")
1.6 RemoveAll方法
d.RemoveAll
Dim d as Object
Set d = CreateObject("Scripting.Dictionary")
d.add "a","苹果"
d.add "b","香蕉"
d.add "c","梨子"``
d.RemoveAll
- 属性
2.1 Count
d.Count
Dim d as Object,i as Integer
Set d = CreateObject("Scripting.Dictionary")
d.add "a","苹果"
d.add "b","香蕉"
d.add "c","梨子"
i=d.Count
2.2 key
d.key(key)=newkey
Dim d as Object,i as Integer
Set d = CreateObject("Scripting.Dictionary")
d.add "a","苹果"
d.key("a")="d"
2.3 item
d.item("a")=newitem
Dim d as Object,i as Integer
Set d = CreateObject("Scripting.Dictionary")
d.add "a","苹果"
d.Item("a")="桔子"
2.4 CompareMode
d.CompareMode=1
参数0(vbBinaryCompare)区分大小写
参数1(vbTextCompare)不区分大小写
Dim d as Object,i as Integer
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode=0
d.add "a","苹果"
d.add "A"="桔子"
网友评论