<p>I want to be able to do:</p>

<pre><code>For Each thing In things
End For
</code></pre>

<p>CLASSIC ASP - NOT .NET!</p>

[{'answer_id': 2312, 'author': 'Brett Veenstra', 'author_id': 307, 'author_profile': 'https://Stackoverflow.com/users/307', 'pm_score': 3, 'selected': True, 'text': '<p>Whatever your [things] are need to be written outside of VBScript.</p>\n\n<p>In VB6, <a href="http://www.vb-helper.com/howto_custom_collection_with_for_each.html" rel="nofollow noreferrer">you can write a Custom Collection class</a>, then you\'ll need to compile to an ActiveX DLL and register it on your webserver to access it.</p>\n'}, {'answer_id': 7725, 'author': 'svandragt', 'author_id': 997, 'author_profile': 'https://Stackoverflow.com/users/997', 'pm_score': 4, 'selected': False, 'text': '<p>Something like this?</p>\n<pre><code>dim cars(2),x\ncars(0)=&quot;Volvo&quot;\ncars(1)=&quot;Saab&quot;\ncars(2)=&quot;BMW&quot;\n\nFor Each x in cars\n  response.write(x &amp; &quot;&lt;br /&gt;&quot;)\nNext\n</code></pre>\n<p>See <a href="http://web.archive.org/web/20140305020029/http://www.w3schools.com/vbscript/vbscript_looping.asp" rel="nofollow noreferrer">www.w3schools.com</a>.</p>\n<p>If you want to associate keys and values <a href="https://web.archive.org/web/20210619173138/https://www.4guysfromrolla.com/webtech/102898-1.shtml" rel="nofollow noreferrer">use a dictionary object</a> instead:</p>\n<pre><code>Dim objDictionary\nSet objDictionary = CreateObject(&quot;Scripting.Dictionary&quot;)\nobjDictionary.Add &quot;Name&quot;, &quot;Scott&quot;\nobjDictionary.Add &quot;Age&quot;, &quot;20&quot;\nif objDictionary.Exists(&quot;Name&quot;) then\n    \' Do something\nelse\n    \' Do something else \nend if\n</code></pre>\n'}, {'answer_id': 75842, 'author': 'Skyhigh', 'author_id': 13387, 'author_profile': 'https://Stackoverflow.com/users/13387', 'pm_score': 2, 'selected': False, 'text': '<p>The closest you are going to get is using a Dictionary (as mentioned by Pacifika)</p>\n\n<pre><code>Dim objDictionary\nSet objDictionary = CreateObject("Scripting.Dictionary")\nobjDictionary.CompareMode = vbTextCompare \'makes the keys case insensitive\'\nobjDictionary.Add "Name", "Scott"\nobjDictionary.Add "Age", "20"\n</code></pre>\n\n<p>But I loop through my dictionaries like a collection</p>\n\n<pre><code>For Each Entry In objDictionary\n  Response.write objDictionary(Entry) &amp; "&lt;br /&gt;"\nNext\n</code></pre>\n\n<p>You can loop through the entire dictionary this way writing out the values which would look like this:</p>\n\n<pre><code>Scott\n20\n</code></pre>\n\n<p>You can also do this</p>\n\n<pre><code>For Each Entry In objDictionary\n  Response.write Entry &amp; ": " &amp; objDictionary(Entry) &amp; "&lt;br /&gt;"\nNext\n</code></pre>\n\n<p>Which would produce</p>\n\n<pre><code> Name: Scott\n Age: 20\n</code></pre>\n'}, {'answer_id': 119352, 'author': 'Aravind', 'author_id': 19536, 'author_profile': 'https://Stackoverflow.com/users/19536', 'pm_score': 0, 'selected': False, 'text': '<p>As Brett said, its better to use a vb component to create collections. Dictionary objects are not very commonly used in ASP unless for specific need based applications. </p>\n'}, {'answer_id': 312122, 'author': 'Mike Henry', 'author_id': 14934, 'author_profile': 'https://Stackoverflow.com/users/14934', 'pm_score': 1, 'selected': False, 'text': "<p>One approach I've used before is to use a property of the collection that returns an array, which can be iterated over.</p>\n\n<pre><code>Class MyCollection\n    Public Property Get Items\n        Items = ReturnItemsAsAnArray()\n    End Property\n    ...\nEnd Class\n</code></pre>\n\n<p>Iterate like:</p>\n\n<pre><code>Set things = New MyCollection\nFor Each thing in things.Items\n    ...\nNext\n</code></pre>\n"}, {'answer_id': 23778188, 'author': 'Pedro Ferreira', 'author_id': 2816279, 'author_profile': 'https://Stackoverflow.com/users/2816279', 'pm_score': 0, 'selected': False, 'text': '<p>Be VERY carefully on using VB Script Dictionary Object!<br />\nJust discover this &quot;<em><strong>autovivication</strong></em>&quot; thing, native on this object: http://en.wikipedia.org/wiki/Autovivification</p>\n<p>So, when you need to compare values, NEVER use a boolen comparison like:<br />\n<code>If objDic.Item(&quot;varName&quot;) &lt;&gt; &quot;&quot; Then</code>...<br />\nThis will <strong>automatically</strong> add the key &quot;<code>varName</code>&quot; to the dictionary (if it doesn\'t exist, with an empty value) , in order to carry on evaluating the boolean expression.</p>\n<p>If needed, use instead <code>If objDic.Exists(&quot;varName&quot;)</code>.</p>\n<p>Just spend a few days knocking walls, with this Microsoft &quot;<em>feature</em>&quot;...<br />\n<a href="http://social.technet.microsoft.com/Forums/scriptcenter/en-US/906ecc76-f0c2-4823-be2a-fb5eaf8179fd/vbscript-dictionary-object-creating-a-key-which-never-existed-but-present-in-another-object" rel="nofollow noreferrer">vbscript-dictionary-object-creating-a-key-which-never-existed-but-present-in-another-object</a></p>\n'}]
['https://Stackoverflow.com/questions/2300', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/193/']