title: How do I swap items in a VB6 collection?
body: <p>If I have a collection of forms (myForms) and I want to switch the position of two forms in the collection (say items 3 and 4 for example), I would expect that the following code would work:</p>
  
  <pre><code>Dim temp as Form
  Set temp = myForms(3)
  Set myForms(3) = myForms(4)
  Set myForms(4) = temp
  </code></pre>
  
  <p>But that doesn't work.  It fails at the third line with the error "Controls property is read only."  If I change the line to:</p>
  
  <pre><code>myForms(3) = myForms(4)
  </code></pre>
  
  <p>I get a type mismatch error instead.</p>