Hi,
I'm iterating through a DataTable, and perfoming some logic to determine whether I should delete certain rows from the table. I keep on getting the error, "Collection was modified; enumeration operation might not execute", but I don't know how to handle it.

I've hacked about with this a bit, and can't get it to work.

Code:
        Dim row As DataRow
        intLoop = 0

        For Each row In dsCopyOfDataView.Tables("tblExchangeRates").Rows
            strCurrentSearchString = dsCopyOfDataView.Tables("tblExchangeRates").Rows(intLoop)(5)
            MsgBox(dsCopyOfDataView.Tables(0).Rows.IndexOf(row).ToString)
            If strPreviousSearchString = strCurrentSearchString Then
                strPreviousSearchString = strCurrentSearchString
                dsCopyOfDataView.Tables("tblExchangeRates").Rows.RemoveAt(intLoop)
            End If
            strPreviousSearchString = strCurrentSearchString
            intLoop = dsCopyOfDataView.Tables(0).Rows.IndexOf(row) + 1
        Next
The thinking behind:

Code:
intLoop = dsCopyOfDataView.Tables(0).Rows.IndexOf(row) + 1
... was to reset intLoop given that I'd just deleted a row, but I keep on getting error:

InvalidOperationException was unhandled
Collection was modified; enumeration operation might not execute.