以下是引用大红袍在2016/2/18 15:57:00的发言:
你在datacolchanged事件,就没必要用select吧?直接find就行,你写在按钮的时候,才需要select的。
If e.DataCol.Name = "日期" Then
Dim drs As List(of DataRow)
Dim dv As Date = e.DataRow("日期")
Dim n As Integer = 0
drs = DataTables("故障报告2").Select("飞机号 = '" & e.DataRow("飞机号") & "'", "日期") '注意要根据日期排序
For Each dr2 As DataRow In drs
If dr2("系统章节").Substring(0, 2) = e.DataRow("系统章节").Substring(0, 2) AndAlso dr2("日期") >= dv.AddDays(-30) AndAlso dr2("日期") < dv Then
n = n + 1
If n >=2 Then
e.DataRow("预警") = "重复性故障"
Exit For
End If
End If
Next
End If
因为是要三次,我采用select的,而且我用select主要是参考了你前面让我看的帮助,这样做实为了减少日期比较次数