也就是说,加上红字的代码后执行,20000行,只要1秒就行了。
Dim st As Date = Date.Now
Dim v As Double
For Each dr As DataRow In DataTables("dtpzzb").DataRows
v = DataTables("dtpzzb").Compute("Count(pzzb142)", "pzzb142 = " & dr("pzzb142"))
Next
Dim Dic As new Dictionary(of DataRow,String)
For Each dr As DataRow In DataTables("dtpzzb").DataRows
Dim jh As new List(of DataRow)
Dim jh1 As new List(of String)
If dr("pzzb9") <> 0 Then
jh = DataTables("dtpzzb").Select(" pzzb8 <> 0 and pzzb142 = '" & dr("pzzb142") & "'")
For Each tr As DataRow In jh
If jh1.Contains(tr("pzzb12")) = False Then
jh1.Add(tr("pzzb12"))
End If
Next
Dim sz() As String
sz = jh1.ToArray
Dim zfc As String
zfc = String.Join(";",sz)
dic.Add(dr,zfc)
ElseIf dr("pzzb8") <> 0 Then
jh = DataTables("dtpzzb").Select(" pzzb9 <> 0 and pzzb142 = '" & dr("pzzb142") & "'")
For Each tr As DataRow In jh
If jh1.Contains(tr("pzzb12")) = False Then
jh1.Add(tr("pzzb12"))
End If
Next
Dim sz() As String
sz = jh1.ToArray
Dim zfc As String
zfc = String.Join(";",sz)
dic.Add(dr,zfc)
End If
Next
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")