ASP-Dictionary对象-基础用法

1、存在

dim d
set d=Server.CreateObject("Scripting.Dictionary")
d.Add "c", "China"
d.Add "i", "Italy"
if d.Exists("c")= true then
Response.Write("键存在。")
else
Response.Write("键不存在。")
end if
set d=nothing

2、遍历值

a=d.Items
for i = 0 To d.Count -1
s = s & a(i)
next
Response.Write(s)

3、遍历主键

a=d.Keys
for i = 0 To d.Count -1
s = s & a(i)
next
Response.Write(s)

4、返回值

d.Add "c", "China"
d.Add "i", "Italy"
Response.Write("项目 i 的值是:" & d.item("i"))

5、修改主键

d.Add "c", "China"
d.Add "i", "Italy"
d.Key("i") = "it"
Response.Write("键 i 已设置为 it,其值是:" & d.Item("it"))

6、返回数量

d.Count

7、删除

DictionaryObject.Remove(key)
DictionaryObject.RemoveAll

3 Comments

  1. Read This method
    八月 19, 2017

    Hey I am so glad I found your blog page, I really found you by mistake, while I was looking on Askjeeve for something else, Anyways I am here now and
    would just like to say kudos for a remarkable post and a all round interesting blog
    (I also love the theme/design), I don’t have time to
    browse it all at the minute but I have saved it and
    also included your RSS feeds, so when I have time I will be back
    to read a great deal more, Please do keep up the excellent
    job.

  2. try What he says
    八月 21, 2017

    Hi, I would like to subscribe for this blog to take newest updates, therefore where can i
    do it please help.

  3. More Hints
    八月 22, 2017

    It’s very effortless to find out any topic on web as compared to
    books, as I found this paragraph at this web site.

Comments are closed.