Code to Create and Manipulate a SimpleList

In the following example, several color values are added to a newly created SimpleList object named ColorList. Once the colors are added, the third color value (blue, with an index value of 2) is removed. Following this, the code iterates through the list, using the Count property to determine the number of items in the SimpleList; in turn, each remaining color is written to the browser.

The example ASP code follows:

<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Dim ColorList, Count
Set ColorList = Server.CreateObject("Commerce.SimpleList")
Call ColorList.Add("Red")
Call ColorList.Add("Green")
Call ColorList.Add("Blue")
Call ColorList.Add("Fuschia")
Call ColorList.Delete(2)

' Count will be 3, not 4.
Count = ColorList.Count

' Output will be "Red  Green  Fuschia" on a line by itself.
For i = 0 To (Count - 1)
    Response.Write ColorList(i) & "  "
Next
Response.Write "<br>"
%>
</BODY>
</HTML>

Copyright © 2005 Microsoft Corporation.
All rights reserved.