format就是四舍五入,比如执行代码
msgbox(format(123.455, "0.00"))
如果重名的金额也计算如总金额,就这样改
For Each ary() As String In DataTables("冲压车间工资表").GetValues("日期|产品名称|生产形式", "日期 is not null and 生产形式 <> '个人'")
Dim drs As List(Of DataRow) = DataTables("冲压车间工资表").Select("日期=#" & ary(0) & "# and 产品名称='" & ary(1) & "' and 生产形式='" & ary(2) & "'")
Dim sum As Double = 0
Dim count As Integer = 0
Dim ls As new List(Of String)
For Each dr As DataRow In drs
Dim fdr As DataRow = DataTables("价格表").find("产品名称 = '" & dr("产品名称") & "'")
If fdr IsNot Nothing
dr("单价") = fdr("单价")
End If
Dim str As String = dr("姓名")
sum += dr("数量") * dr("单价")
If ls.Contains(str) = False Then
count += 1
ls.add(str)
dr("备注") = dr("备注").replace("重复", Nothing)
Else
dr("备注") = "重复" & dr("备注").replace("重复", Nothing)
End If
Next
For Each dr As DataRow In drs
If dr("备注") Like "*旷工*" OrElse dr("备注") Like "*重复*" Then
dr("分配金额") = Nothing
Else
dr("分配金额") = format(sum/count, "0.00")
End If
Next
Next
For Each dr As DataRow In DataTables("冲压车间工资表").Select("生产形式 = '个人'")
dr("备注") = dr("备注").replace("重复", Nothing)
dr("分配金额") = dr("数量") * dr("单价")
Next
[此贴子已经被作者于2016/2/6 14:14:17编辑过]