Skip to content

Instantly share code, notes, and snippets.

@batasrki
Created August 12, 2008 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save batasrki/5144 to your computer and use it in GitHub Desktop.
Save batasrki/5144 to your computer and use it in GitHub Desktop.
Private Function RemoveEmptyRows(ByVal dt As DataTable) As DataTable
Dim rowIndexes As New ArrayList
Dim changed As New DataTable
dt.AcceptChanges()
For i As Integer = 0 To dt.Rows.Count - 1
If dt.Rows(i).Item(2).ToString = String.Empty Then
rowIndexes.Add(i)
End If
Next
For Each index As Integer In rowIndexes
dt.Rows(index).Delete()
Next
dt.AcceptChanges()
changed = dt.Copy
Return changed
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment