Exists 方法

描述
如果在 Dictionary 对象中存在指定键,返回 True;如果不存在,返回 False
语法
object.Exists(key)

Exists 方法的语法有以下部分:

参数 描述
object 必选。应为 Dictionary 对象的名称。
key 必选。Key 为在 Dictionary 对象中要查找的值。

说明
下面例子举例说明如何使用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") Then
    msg = "指定的键存在。"
  Else
    msg = "指定的键不存在。"
  End If
  KeyExistsDemo = msg
End Function



本文档由兄弟工作组制作完成,部分内容摘自因特网公开的文档资料,欢迎您和我们一起完善此文档。兄弟工作组网站: www.vrbrothers.com