如果 Dictionary 对象中存在所指定的关键字则返回 true,否则返回 false。
object.Exists(key)
下面这个例子说明了 Exists 方法的用法。
[JScript] function keyExists(k) { var fso, s = ""; d = new ActiveXObject("Scripting.Dictionary"); d.Add("a", "Athens"); d.Add("b", "Belgrade"); d.Add("c", "Cairo"); if (d.Exists(k)) s += "Specified key exists."; else s += "Specified key doesn't exist."; return(s); } [VBScript] Function KeyExistsDemo Dim d, msg ' Create some variables. Set d = CreateObject("Scripting.Dictionary") d.Add "a", "Athens" ' Add some keys and items. d.Add "b", "Belgrade" d.Add "c", "Cairo" Ifd.Exists(
"c")
Then msg = "Specified key exists." Else msg = "Specified key doesn't exist." End If KeyExistsDemo = msg End Function
Add 方法 (Dictionary) | Items 方法 | Keys 方法 | Remove 方法 | RemoveAll 方法
应用于:Dictionary 对象