Visual Basic Scripting Edition | 語言參考 |
如果在 Dictionary 對象中存在指定鍵,返回 True;如果不存在,返回 False。
object.Exists(key)
object
必選項. 總是 Dictionary 對象名稱。
key
必選項. 在Dictionary 對象中查找的Key 值。
下面例子舉例說明如何使用Exists 方法:
Function KeyExistsDemo Dim d, msg '
創(chuàng)建一些變量。Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens" '
添加一些鍵和項目。d.Add "b", "Belgrade"
d.Add "c", "Cairo"
If d.Exists("c") Then
msg = "
指定的鍵存在。"
Else
msg = "
指定的鍵不存在。"
End If
KeyExistsDemo = msg
End Function
Add 方法(Dictionary) | Items 方法 | Keys 方法 | Remove 方法 | RemoveAll 方法
應用于:Dictionary 對象