修改下思路,基本上达到秒改,但是保存到数据库还是比较慢,没办法。代码如下
Dim st As Date = Date.Now
'要测试耗时的代码
Dim dt As DataTable = DataTables("D")
Dim lst As List(of DataRow) = dt.Select("","Code")
Dim iMax As Integer = lst.Count -1
For IntA As Integer = 0 To iMax
If IntA < IMax Then
Dim dr1 As DataRow = lst(IntA)
Dim dr2 As DataRow = lst(IntA+1)
Dim str1 As String = dr1("Code")
Dim str2 As String = dr2("Code")
dr1("Tree") = not str2.StartsWith(str1)
Else
lst(IntA)("Tree") = True
End If
Next
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")