ASP Dictionary Object

Last updated: August 25, 2026.

The VBScript Scripting.Dictionary object stores key-value pairs. It is useful for lookups, counters, and small in-memory collections inside a Classic ASP request.

Create and populate a dictionary

<%
Dim prices
Set prices = Server.CreateObject("Scripting.Dictionary")
prices.CompareMode = vbTextCompare

prices.Add "widget", 12.50
prices.Add "gadget", 19.95

If prices.Exists("Widget") Then
    Response.Write FormatCurrency(prices("Widget"))
End If

Set prices = Nothing
%>

Set CompareMode before adding keys. Use vbTextCompare for case-insensitive text keys or vbBinaryCompare for exact matching.

Loop through keys

<%
Dim key
For Each key In prices.Keys
    Response.Write Server.HTMLEncode(CStr(key)) & ": "
    Response.Write Server.HTMLEncode(CStr(prices(key))) & "<br>"
Next
%>
MemberPurpose
AddAdds a new key and value.
ExistsTests whether a key is present.
ItemReads or replaces a value.
RemoveDeletes one key.
Keys, ItemsReturns arrays for iteration.

Do not store an unlocked dictionary in Application state and update it concurrently; use Application.Lock and Application.UnLock, or persistent storage designed for concurrent access.

admin

admin

Leave a Reply

Your email address will not be published.