Looping Through An ASP Dictionary
Here's some code that adds a few items to a dictionary and then loops through them using a for each loop.
Dim StateList
Dim Key
set StateList = Server.CreateObject("Scripting.Dictionary")
StateList.Add "CA", "California"
StateList.Add "NV", "Nevada"
StateList.Add "FL", "Florida"
For Each Key in StateList
Response.Write Key & " is " & StateList(Key) & "<br>"
Next
Here's one more example showing how to loop through Request.QueryString. Just to show you that you can.
Dim Key
For each Key in Request.QueryString
Response.Write Key & "=" & Request.QueryString(Key)
Next
Exists and Remove
Use Exists to check if a key is in the associative array and Remove to delete it. It's a good idea to check if an element exists prior to deleting it. Here's how:
If StateList.Exists("FL") Then
StateList.Remove("FL")
End If
If you fail to check if an element exists and it doesn't, you will get the following error:
Microsoft VBScript runtime error '800a802b'
Element not found
/path/yourpage.asp, line 51
Sorting
No built-in sort function. However, Microsoft provided a good example of how to do this at http://support.microsoft.com/kb/246067.