如果在 Dictionary 對象中存在指定鍵,返回 True;如果不存在,返回 False。
object.Exists(key)
object
必選項. 總是 Dictionary 對象名稱。
key
必選項. 在Dictionary 對象中查找的Key 值。
下面例子舉例說明如何使用Exists 方法:
Function KeyExistsDemo Dim d, msg '創建一些變量。Set d = CreateObject("Scripting.Dictionary")d.Add "a", "Athens" '添加一些鍵和項目。d.Add "b", "Belgrade"d.Add "c", "Cairo"If d.Exists("c") Thenmsg = "指定的鍵存在。"Elsemsg = "指定的鍵不存在。"End IfKeyExistsDemo = msgEnd Function
新聞熱點
疑難解答