标签:tps server object 遍历 res this exists href cti
Dim objMyData
Set objMyData = Server.CreateObject(“Scripting.Dictionary”)
CompareMode (仅用于VBScript)设定或返回键的字符串比较模式
Count 只读。返回Dictionary里的键/条目对的数量
Item(key) 设定或返回指定的键的条目值
Key(key) 设定键值
Add(key,item) 增加键/条目对到Dictionary
Exists(key) 如果指定的键存在,返回True,否则返回False
Items() 返回一个包含Dictionary对象中所有条目的数组
Keys() 返回一个包含Dictionary对象中所有键的数组
Remove(key) 删除一个指定的键/条目对
RemoveAll() 删除全部键/条目对
objMyData.Add “MyKey”, “MyItem” ‘Add Value MyItem with key MyKey
objMyData.Add “YourKey”, ”YourItem” ‘Add value YourItem with key YourKey
blnIsThere = objMyData.Exists(“MyKey”) ‘Returns True because the item exists
strItem = objMyData.Item(“YourKey”) ‘Retrieve value of YourKey
strItem = objMyData.Remove(“MyKey”) ‘Retrieve and remove YourKey
objMyData.RemoveAll ‘Remove all the items
可以通过修改键的值,或通过修改与特定的键关联的条目的数据,来改变存储在Dictionary内的数据。下面的代码改变键为MyKey的条目中的数据。
ObjMyData.Item(“MyKey”) = “NewValue” ‘ In VBScript
arrKeys = objMyData.Keys ‘Get all the keys into an array
arrItems = objMyData.Items ‘Get all the items into an array
For intLoop = 0 To objMyData.Count –1 ‘Iterate through the array
StrThisKey = arrKeys(intLoop) ‘This is the key value
StrThisItem = arrItems(intLoop) ‘This is the item (data) value
Next
在VBScript里也可以使用For Each … Next语句完成同样的功能:
‘ Iterate the dictionary as a collection in VBScript
For Each objItem in arrItems
Response.Write objItem & “ = “ & arrItems(objItem) & “<BR>”
Next
引用:
https://blog.csdn.net/zbyufei/article/details/5822965
标签:tps server object 遍历 res this exists href cti
原文地址:https://www.cnblogs.com/kutsu/p/14072843.html