If e.DataCol.Name.StartsWith("尺码_") Then Dim sum1 As Double = DataTables("入库表").compute("sum(" & e.DataCol.name & ")", "款号='" & e.DataRow("款号") & "'") Dim sum2 As Double = DataTables("出库表").compute("sum(" & e.DataCol.name & ")", "款号='" & e.DataRow("款号") & "'") If sum2-e.OldValue+e.NewValue > sum1 Then msgbox("库存不够") e.cancel = True End If End If