Name

Dictionary.Items Method

Syntax

                  dictionaryobject.Items
dictionaryobject

Use: Required

Data Subtype: Dictionary object

A reference to a Dictionary object.

Return Value

A Variant array.

Description

Returns an array containing all the items in the specified Dictionary object.

Rules at a Glance

The returned array is always a zero-based variant array whose data subtype matches that of the items in the Dictionary object.

Example

The following ASP example uses Global.asa to generate a session-level Dictionary object containing the names of some Shakespearean plays, then uses the Items property to display them to a web page. The contents of Global.asa are:

<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER">

Sub Session_OnStart
   Dim oDict
   Set oDict = Server.CreateObject("Scripting.Dictionary")
   oDict.Add "MER", "The Merchant of Venice"
   oDict.Add "HAM", "Hamlet"
   oDict.Add "TEM", "The Tempest"
   oDict.Add "MAC", "MacBeth"
   oDict.Add "OTH", "Othello"
   oDict.Add "ADO", "Much Ado about Nothing"
   oDict.Add "LEA", "King Lear"
   Set Session.Contents.Item("PLAYS") = oDict
End Sub 

</SCRIPT>

The web page that actually retrieves the array returned by the Items property is:

<HTML> <HEAD> <TITLE>Shakespeare's Plays</TITLE> </HEAD> <BODY> <CENTER><H2>Selected Shakespeare Plays</H2></CENTER> <P> Click on the play about which you'd like more information:<P> <% Dim sPlay, sPlays sPlays = Session.Contents("PLAYS").Items For Each sPlay in sPlays Response.Write "<A HREF=" & chr(34) & sPlay & ".htm" & _ chr(34) & ">" & sPlay & "</A><P>" ...

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.