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.
My code is as follows:
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=" & invitation_array(v) & ""
Set rsInvitation = Conn.Execute(invitationStr)
For v=LBound(invitation_array) to UBound(invitation_array)
If CDate(rsInvitation("Dato")) < 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
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?