title: Looping through a Scripting.Dictionary using index/item number
body: <p>Similar to <a href="https://stackoverflow.com/a/9836919/698590">this issue</a>, when using a <code>Scripting.Dictionary</code> object in VBA, the outcome of the code below is unexpected.</p>
  
  <pre><code>Option Explicit
  
  Sub test()
  
      Dim d As Variant
      Dim i As Integer
      Dim s As String
      Set d = CreateObject("Scripting.Dictionary")
  
      d.Add "a", "a"
      Debug.Print d.Count ' Prints '1' as expected
  
      For i = 1 To d.Count
          s = d.Item(i)
          Debug.Print s ' Prints ' ' (null) instead of 'a'
      Next i
  
      Debug.Print d.Count ' Prints '2' instead of '1'
  
  End Sub
  </code></pre>
  
  <p>Using a zero-based index, the same outcome is achieved:</p>
  
  <pre><code>For i = 0 To d.Count - 1
      s = d.Item(i)
      Debug.Print s
  Next i
  </code></pre>
  
  <p>Watching the object, I can actually see that it has two items, the key for the newly added is <code>1</code>, as added from <code>i</code>. If I increase this loop to a higher number, then the number of items in the dictionary is increased, once for each loop.</p>
  
  <p><em>I have tested this in Office/VBA 2003, 2010, and 2013. All exhibit the same behavior, and I expect other versions (2007) will as well.</em></p>
  
  <p>I can work around this with other looping methods, but this caught me off guard when I was trying to store objects and was getting an <strong>object expected error</strong> on the <code>s = d.Item(i)</code> line.</p>
  
  <p>For the record, I know that I can do things like this:</p>
  
  <pre><code>For Each v In d.Keys
      Set o = d.item(v)
  Next v
  </code></pre>
  
  <p>But I'm more curious about why I can't seem to iterate through the items by number.</p>