Microsoft Scripting Runtime
Dictionary Collection / Exists Method
Key value being searched for in the Dictionary object.
In This Topic
    Exists Method
    In This Topic
    Description
    Returns true if a specified key exists in the Dictionary object, false if it does not.
    Syntax
    Visual Basic
    Public Function Exists( _
       ByRef Key As Variant _
    ) As Boolean
    Parameters
    Key
    Key value being searched for in the Dictionary object.
    Example

    The following example illustrates the use of the Exists method.

    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);
    }
    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"
       If d.Exists("c") Then
          msg = "Specified key exists."
       Else
          msg = "Specified key doesn't exist."
       End If
       KeyExistsDemo = msg
    End Function
    See Also