VBScript » Dictionary » Exists

Version: 2.0

Syntax:
object.Exists (keyvalue)
Keyvalue
The value of the key associated with the item being returned or set.

The Exists method is used to determine whether a key already exists in the specified Dictionary. Returns True if it does and False otherwise.

Examples

Code:
<%
dim guitars
set guitars=CreateObject("Scripting.Dictionary")
guitars.Add "e", "Epiphone"
guitars.Add "f", "Fender"
guitars.Add "g", "Gibson"
guitars.Add "h", "Harmony"
If guitars.Exists("g") Then
guitars.Item("g") = "Guild"
End If
%>
Output:
"Epiphone"
"Fender"
"Guild"
"Harmony"
Explanation:

This code uses the Exists method to see if the key with the value of 'g' exists in the Dictionary object and, if it does, changes its corresponding item value.