다음을 통해 공유


Exists Method (Script Runtime)

Returns true if a specified key exists in the Dictionary object, false if it does not.

                      object
                      .Exists(
                      key
                      ) 

Arguments

  • Object
    Required. Always the name of a Dictionary object.

  • Key
    Required. Key value being searched for in the Dictionary object.

Remarks

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 does not exist.";
    return(s);
}
Function KeyExists(k)
    Dim d, msg
    Set d = CreateObject("Scripting.Dictionary")
    d.Add "a", "Athens"
    d.Add "b", "Belgrade"
    d.Add "c", "Cairo"
    If d.Exists(k) Then
        msg = "Specified key exists."
    Else
        msg = "Specified key does not exist."
    End If
    KeyExists = msg
End Function

Applies To:

Dictionary Object

See Also

Reference

Add Method (Script Runtime)

Items Method

Keys Method

Remove Method (Script Runtime)

RemoveAll Method

Change History

Date

History

Reason

September 2009

Modified Visual Basic Scripting Edition (VBScript) example.

Content bug fix.