Open In App

ASP Item Property

Last Updated : 19 Mar, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The ASP Item Property is used to return or set the value of an item in the Dictionary Object.

Syntax:

DictionaryObject.Item(key)[=newitem]

Parameter Values:

  • key: It specifies the key that is associated with an item. It is a required attribute.
  • newitem: It specifies the new item that has to be set for the given key.

Example: The below code demonstrates the ASP Dictionary.Item Property.

ASP




<%
Dim dict
  
'Create a new dictionary
Set dict=Server.CreateObject("Scripting.Dictionary")
  
'Add values to the dictionary
dict.Add "g","green"
dict.Add "r","red"
dict.Add "p","purple"
  
'Getting a value from the dictionary
Response.Write("Value of key 'p' is: " & dict.Item("p"))
  
'Setting a new value to the key
dict.Item("p") = "violet"
  
'Getting the value again from the dictionary
Response.Write("<br>Value of key 'p' is: " & dict.Item("p"))
%>


Output:

Value of key 'p' is: purple
Value of key 'p' is: violet

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads