说明:(1)在表A中,如果“是否加权”为false,则“加权系数”不进行计算; (2)如果“是否加权”为true,则“加权系数”进行计算;代码如下:
Select Case e.DataCol.name
Case "是否加权","面试成绩"
Dim zgf1, zgf2, zdf1, zdf2 As Double
Dim dt As Table = Tables("表A")
For Each dr As Row In dt.Rows
If dr("是否加权")=False Then
dr("加权系数") = Nothing
ElseIf dr("是否加权")=True Then
Dim drs As List(Of Row) = Tables("表A").Select("天数='" & dr("天数") & "' and 面试室='" & dr("面试室") & "'And 面试成绩 Is Not Null", "面试成绩")
zgf1 = drs(drs.Count-1)("面试成绩")
zgf2 = drs(drs.Count-2)("面试成绩")
zdf1 = drs(0)("面试成绩")
zdf2 = drs(1)("面试成绩")
Dim sum As Double = Tables("笔试成绩").Compute("sum(面试成绩)","天数='" & dr("天数") & "' and 面试室='" & dr("面试室") & "'")
If e.Form.Controls("个数").text = 2 Then
Dim mss As Double = (sum - zgf1 - zdf1) /( drs.Count - 2)
Dim jqz As Double = dt.Compute("avg(mss)", "天数='" & dr("天数") & "'")
dr("加权系数") = Format(jqz/mss,"0.0000")
ElseIf e.Form.Controls("个数").text = 4 Then
Dim mss As Double = (sum - zgf1 - zgf2 - zdf1 - zdf2) /( drs.Count - 4)
Dim jqz As Double = dt.Compute("avg(mss)", "天数='" & dr("天数") & "'")
dr("加权系数") = Format(jqz/mss,"0.0000")
End If
End If
Next
End Select
但就是显示错误,不知道什么地方出了问题,请专家指导。
[此贴子已经被作者于2020/7/10 8:50:27编辑过]