Dim sum2 As Double
sum2 = DataTables("XMFP").Compute("Sum(当月人天)","BH = '" & e.DataRow("BH") & "' ")
Dim dr As DataRow = DataTables("xmzb").find("BH = '" & E.DataRow("bh") & "'")
Dim st As Date = Date.Now
if dr isnot nothing then
dr("剩余") = dr("apc") - sum2
dr("总") = dr("apc") - dr("剩余")
end if
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")
看不出优化的可能,其中需要做Sum运算费时间,这个和你的记录数多少相关.但是若想无错运行,需要加入红笔代码