Dim s1,s2,s3 As double Dim dr As DataRow = e.DataRow Dim s As String = "[克重] = " & dr("克重") & " And [编号] = '" & dr("编号") & "' And [幅宽] = " & dr("幅宽") s1 = DataTables("期初库存").Compute("Sum(重量)",s) s2 = DataTables("生产清单").Compute("Sum(重量)",s) s3 = DataTables("发货清单").Compute("Sum(重量)",s) dr("重量") = s1+s2-s3