0
我正在遍歷表格行。如果行的行是空的,我只想刪除行。 它顯示一個錯誤我無法從循環中移除表格中的一行
Public Sub RemoveBlankRow(ByVal MyDataTable As DataTable)
Try
Dim MyRowStr As String = String.Empty
For Each MyRow As DataRow In MyDataTable.Rows
MyRowStr = ""
For Each MyCellText As Object In MyRow.ItemArray
MyRowStr = MyRowStr + MyCellText.ToString
Next
MyRowStr = Replace(MyRowStr, "0", " ")
MyRowStr = Replace(MyRowStr, ".", " ")
If MyRowStr.Trim = String.Empty Then
MyDataTable.Rows.Remove(MyRow)
End If
Next
Catch ex As Exception
End Try
End Sub
如何克服這個問題?
只是說明:string.Empty與null不同。 – 2010-04-02 10:08:28