For Each dw As String In DataTables("问卷答案").GetValues("单位","年级 = '" & nj & "'")
Dim dr As DataRow = DataTables(Wj & "卷二得分").AddNew()
dr("单位") = dw
dr("年级") = nj
dr("题号") = "卷二得分"
Dim ddr As DataRow = DataTables("校名设置").Find("单位 = '" & dw & "'")
dr("单位代码") = ddr("单位代码")
Dim jdrs As List(of DataRow) = DataTables("对应科目").Select("科目 = '卷二'")
For Each jdr As DataRow In jdrs
Dim rdr As DataRow = DataTables("分值").Find("类别 = '卷二' And 题号 = '" &dr("题号")& "'")
dr("调查人数") = dr("调查人数") + (dt.DataTable.Compute("Count("& jdr("题号") &")", "" & jdr("题号") & " <> '""' and [单位] = '" & dr("单位") & "'And [年级] = '" & dr("年级") & "'"))/12
For Each bm As DataTable In DataTables
If bm.name <> "校名设置" AndAlso bm.Name <> "分值" AndAlso bm.Name <> "对应科目" AndAlso bm.Name <> "问卷答案"
dr("卷二平均分") = DataTables(Wj & "卷二得分").Compute("Sum(卷二平均分)","单位 = '" & dr("单位") & "' And 年级 = '" & dr("年级") & "'")
End If
Next
Next
Next
如何修改此代码?请指教。谢谢!
要求:卷二得分=卷二平均分的和(单位=单位,年级=年级)

此主题相关图片如下:统计结果.png
[此贴子已经被作者于2016/7/21 10:41:30编辑过]