Create a dictionary object with the following keys and item using VBScript.
i.
Keys
|
Items
|
Key1
|
Item1
|
Key2
|
Item2
|
Key3
|
Item3
|
ii.
Check whether “key3” exists?
iii.
Show the value of “key1”
iv.
Change the value of a key or item
v.
Show the iteration through a dictionary,
with the list of keys and items
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<% DIM dict
Set
dict=Server.CreateObject("Scripting.Dictionary")
dict.Add "Key1","Item1"
dict.Add "Key2","Item2"
dict.Add "Key3","Item3"
'p= dict.Exists "Key3"
response.Write("Does Key3 exists? ")
response.Write(dict.Exists("Key3"))
response.Write("<br>Return the value of Key1 ")
response.Write(dict.Item("Key1"))
response.Write("<br>The
changed value of the given Key1 is as<br>")
dict.Item("Key1")="Ankura"
response.Write(dict.Item("Key1"))
dim
arrKey,arrItem
arrKey=Key()
arrItem=Item()
for
i=0 to dict.Count-1
Response.Write
("<br>Key = "& arrKey(i)&" Item =
"& arrItem(i))
next
%>
</body>
</html>
0 comments:
Feel free to contact the admin for any suggestions and help.