Private Function ColumnEqual(ByVal A As Object, ByVal B As Object) As Boolean
If A Is DBNull.Value AndAlso B Is DBNull.Value Then
Return True
End If
If A Is DBNull.Value OrElse B Is DBNull.Value Then
Return False
End If
Return A.Equals(B)
End Function
...
Public lastV As Object
...
For Each dr In wData.Rows
If lastV Is Nothing OrElse Not ColumnEqual(lastV, dr("table1")) Then
''check if first value is nothing
If lastV = Nothing Then
lastV = "00"
l = "0"
Else
dr("t1") = lastV
dr("n1") = l
End If
ListBox1.Items.Add(lastV & " <--> " & l)
lastV = dr("table1")
l = 1
ElseIf lastV Is Nothing OrElse ColumnEqual(lastV, dr("table1")) Then
l += 1
End If
Next
我使用这段代码来循环我的DataRow
.
它将每条记录添加到 aListBox
中,但不会将 中的最后一条记录添加
DataRow
到列表中。
有什么帮助吗?