title: Remove multiple elements in dynamic array in Classic ASP
body: <p>I'm trying to iterate through a dynamic array and remove elements if the date has been exceeded. The array has been generated from a comma separated string.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>Sub delete(ByRef ar, ByVal idx)
      Dim i
      Dim ub
  
      ub = UBound(ar) - 1
  
      For i = idx To ub
          ar(i) = ar(i + 1)
      Next
  
      ReDim Preserve ar(ub)
  
  End Sub
  
  
      Dim invitation,invitation_array
      invitation = rs("visningID")
      invitation_array=split(invitation,",")
  
      invitationStr = "Select * From visningTable Where Id=" &amp; invitation_array(v) &amp; ""
      Set rsInvitation = Conn.Execute(invitationStr)
  
  
  For v=LBound(invitation_array) to UBound(invitation_array)
  
    If CDate(rsInvitation("Dato")) &lt; Date then
  
      Dim ar
      Dim i
  
      ar = invitation_array
  
      delete ar, v  '' pass the name of the array, and the index of the element to delete
  
    end if
  </code></pre>
  
  <p>I can't get it to remove the correct elements and in the end the array is completely messed up?
  Where do I go wrong?</p>