老师:您好!此主题相关图片如下:8481fd9bbf3f2bee82a3c8c59eb3184.jpg
上表中,我有4行相同的标识(bs),相同的工序耗时,我想将这4行的重量加起来,取一行的工序耗时,按每一行的重量占总重量的比例,去分劈工序耗时,然后再逐行到实际耗时列中,我的代码就填充了一行。其余三行没填进去。请指教!谢谢!(其实:四行实际耗时:是7.73,7.05,4.09,13.65,表中就填了一个7.73)
Dim Nas As New List(Of String)
Dim l As Integer
For Each bbm As String In DataTables("实时工序计算表").GetValues("bs")
l = bbm.Length
If l = 18 Then
nas.Add(bbm)
End if
Next
Dim j As Integer
Dim dzl, gxhs, zzl As Double
For Each na As String In Nas
Dim m As Integer = DataTables("实时工序计算表").Compute("count(bs)", "bs='" & na & "'")
If m > 1 Then
zzl = DataTables("实时工序计算表").Compute("sum(重量)", "bs='" & na & "'")
End If
For j = 1 To m
Dim dr As DataRow = DataTables("实时工序计算表").find("bs='" & na & "'")
If dr IsNot Nothing Then
gxhs = dr("工序耗时")
dzl = dr("重量")
dr("实际耗时") = dzl * gxhs / zzl
End If
Next
Next