' For each message ' I just realized I don't know how to negatively decrement in VB ' you'll have to fill in the blanks on that one ' In C# it would be: ' for (lnCounter = loDataProvider.nCount - 1; lnCounter >=0; lnCounter--) For lnCounter = loDataProvider.nCount - 1 To 0 loRow = loDataProvider.oDataSet.Tables("Temp").Rows(lnCounter) ' If we have to delete the row If True Then loRow.Delete() End If NextDeleting forward rather than backward will work only if you have no rows with a RowState of Added. An Added Row gets physically removed from the DataTable (decreasing the number of Rows in the Rows collection), whereas all other rows get changed to a RowState of Deleted and the number of Rows remain the same.
> loDataView = New DataView(loDataProvider.oDataSet.Tables.Item(0)) > > loDataView.RowFilter = "Flag=1" > > ' Delete all records which have been flagged > For Each loRowView In loDataView > loRowView.Delete() > Next > > loDataView.RowFilter = "" > loDataView.Table.AcceptChanges() > > ' Adjust the count > loDataProvider.nCount = loDataProvider.oDataSet.Tables("Temp").Rows.Count >>
> ' For each message > For lnCounter = 0 To loDataProvider.nCount - 1 > loRow = loDataProvider.oDataSet.Tables("Temp").Rows(lnCounter) > > ' If we have to delete the row > If True Then > loRow.Delete() > End If > > Next >