Skip to content
Related Articles

Related Articles

Improve Article
ASP Add Method
  • Last Updated : 22 Mar, 2021

The ASP Dictionary.Add Method is used to add a new key-value pair to the Dictionary Object.

Syntax:

DictionaryObject.Add(key, item)

Parameters: This method has two parameters as mentioned above and described below:

  • key: It specifies the name of the key to be inserted. It is a required parameter.
  • item: It specifies the value that has to be associated with the key in the key-value pair.

Example: The below code demonstrates the ASP Dictionary.Add Method.

ASP




Dim dict
  
'Create a new dictionary
Set dict=Server.CreateObject("Scripting.Dictionary")
  
'Add values to the dictionary
dict.Add "w","white"
dict.Add "b","blue"
dict.Add "br","Brown"
dict.Add "p","Pink"
  
'Retrieve some values from the dictionary
Response.Write("Value of key 'br' is: " & dict.Item("br"))
Response.Write("<br>Value of key 'p' is: " & dict.Item("p"))
%>

Output:

Value of key 'br' is: Brown
Value of key 'p' is: Pink
My Personal Notes arrow_drop_up
Recommended Articles
Page :