以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=134240) |
|
-- 作者:nxdx112 -- 发布时间:2019/4/30 16:39:00 -- 求代码 均分代码 Post By:2019/4/30 16:16:00 [只看该作者]
|
|
-- 作者:有点甜 -- 发布时间:2019/4/30 16:49:00 --
dr("均分值") = dr("平均分") * 0.7 + dr("及格率") * 20 + dr("优秀率") *10
|
|
-- 作者:nxdx112 -- 发布时间:2019/4/30 17:29:00 -- 不同班级的不同科目也是这样的吗? |
|
-- 作者:有点甜 -- 发布时间:2019/4/30 17:40:00 -- 以下是引用nxdx112在2019/4/30 17:29:00的发言:
不同班级的不同科目也是这样的吗?
不同班级的条件,你在filter那里设置了啊
Dim filter = "班级=\'aabbcc\'" |
|
-- 作者:nxdx112 -- 发布时间:2019/5/5 14:24:00 -- 按班计算及格率与优秀率 DataColChanged 代码 Dim dr As DataRow = e.DataRow Dim dt As DataTable =DataTables("学生成绩") Select Case e.DataCol.name Case "名称", "年级", "班级", "科目" If dr.IsNull("名称") = False AndAlso dr.IsNull("年级") = False AndAlso dr.IsNull("班级") = False AndAlso dr.IsNull("科目") = False Then Dim filter As String = "名称= \'" & dr("名称") & "\' and 年级 = \'" & dr("年级") & "\' and 班级 = \'" & dr("班级") & "\'" dr("最高分") = dt.Compute("Max(" & dr("科目") & ")", filter) dr("最低分") = dt.Compute("Min(" & dr("科目") & ")", filter) dr("平均分") = dt.Compute("Avg(" & dr("科目") & ")", filter) dr("成绩分布_0分") = dt.Compute("Count(姓名)", dr("科目") & " = 0 and " & filter) dr("成绩分布_0至9分") = dt.Compute("Count(姓名)", dr("科目") & " > 0 And " & dr("科目") & " < 10 and " & filter) dr("成绩分布_10至19分") = dt.Compute("Count(姓名)", dr("科目") & " >= 10 And " & dr("科目") & " < 20 and " & filter) dr("成绩分布_20至29分") = dt.Compute("Count(姓名)", dr("科目") & " >= 20 And " & dr("科目") & " < 30 and " & filter) dr("成绩分布_30至39分") = dt.Compute("Count(姓名)", dr("科目") & " >= 30 And " & dr("科目") & " < 40 and " & filter) dr("成绩分布_40至49分") = dt.Compute("Count(姓名)", dr("科目") & " >= 40 And " & dr("科目") & " < 50 and " & filter) dr("成绩分布_50至59分") = dt.Compute("Count(姓名)", dr("科目") & " >= 50 And " & dr("科目") & " < 60 and " & filter) dr("成绩分布_60至69分") = dt.Compute("Count(姓名)", dr("科目") & " >= 60 And " & dr("科目") & " < 70 and " & filter) dr("成绩分布_70至79分") = dt.Compute("Count(姓名)", dr("科目") & " >= 70 And " & dr("科目") & " < 80 and " & filter) dr("成绩分布_80至89分") = dt.Compute("Count(姓名)", dr("科目") & " >= 80 And " & dr("科目") & " < 90 and " & filter) dr("成绩分布_90至99分") = dt.Compute("Count(姓名)", dr("科目") & " >= 90 And " & dr("科目") & " < 100 and " & filter) dr("成绩分布_100分") = dt.Compute("Count(姓名)", dr("科目") & " = 100 and " & filter) dr("成绩分布_100至119分") = dt.Compute("Count(姓名)", dr("科目") & " > 100 And " & dr("科目") & " < 120 and " & filter) dr("成绩分布_120分") = dt.Compute("Count(姓名)", dr("科目") & " = 120 and " & filter) dr("及格人数") = dt.Compute("Count(姓名)", dr("科目") & " >= 60 and " & filter) dr("不及格人数") = dt.Compute("Count(姓名)", dr("科目") & " < 60 and " & filter) dr("考试人数") = dt.Compute("Count(姓名)", dr("科目") & " >= 0 and " & filter) dr("均分值") = dr("平均分") * 0.7 + dr("及格率") * 20 + dr("优秀率") *10 dr("优秀率") = dt.Compute("Count(姓名)", dr("科目") & " >= 85") / dt.Compute("Count(姓名)") dr("及格率") = dt.Compute("Count(姓名)", dr("科目") & " >= 60") / dt.Compute("Count(姓名)") End If End Select 计算出来有问题题具体在标色的,不能每个班不同的的及格率与优秀率。如下图这两列的数据一样,不能每个班不同的的及格率与优秀率 Dim dt2 As DataTable = DataTables("成绩分布") dt2.DataRows.Clear() \'清除原有数据 Dim dt As DataTable = DataTables("学生成绩") Dim kms() As String = {"语文","数学","英语","物理","化学","政治","历史","地理","生物"} For Each ary() As String In dt.GetValues("名称|年级|班级") For Each km As String In kms Dim ndr As DataRow = dt2.AddNew ndr("名称") = ary(0) ndr("年级") = ary(1) ndr("班级") = ary(2) ndr("科目") = km Next Next Messagebox.Show("统计完毕!") [此贴子已经被作者于2019/5/5 14:30:37编辑过]
|
|
-- 作者:有点甜 -- 发布时间:2019/5/5 14:44:00 -- 比如
dr("优秀率") = dt.Compute("Count(姓名)", dr("科目") & " >= 85 and " & filter) / dt.Compute("Count(姓名)", filter) |
|
-- 作者:nxdx112 -- 发布时间:2019/5/5 14:51:00 -- 换了个思路可以了 dr("及格率") = dr("及格人数")/dr("考试人数") * 100 dr("优秀率") = dr("优秀人数")/dr("考试人数") * 100 |