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
Else
Dim drs As List(Of dataRow) = dataTables("表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