以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]代码简化 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=143440) |
-- 作者:cqlpjks -- 发布时间:2019/11/25 10:50:00 -- [求助]代码简化 dr("语文有效分/人数") = DataTables("成绩库").Compute("count(单位)", " 语文 >= \'" & ldr("语文B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") dr("数学有效分/人数") = DataTables("成绩库").Compute("count(单位)", " 数学 >= \'" & ldr("数学B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") dr("英语有效分/人数") = DataTables("成绩库").Compute("count(单位)", " 英语 >= \'" & ldr("英语B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") dr("物理有效分/人数") = DataTables("成绩库").Compute("count(单位)", " 物理 >= \'" & ldr("物理B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") dr("化学有效分/人数") = DataTables("成绩库").Compute("count(单位)", " 化学 >= \'" & ldr("化学B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") dr("生物有效分/人数") = DataTables("成绩库").Compute("count(单位)", " 生物 >= \'" & ldr("生物B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") dr("政治有效分/人数") = DataTables("成绩库").Compute("count(单位)", " 政治 >= \'" & ldr("政治B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") dr("历史有效分/人数") = DataTables("成绩库").Compute("count(单位)", " 历史 >= \'" & ldr("历史B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") dr("地理有效分/人数") = DataTables("成绩库").Compute("count(单位)", " 地理 >= \'" & ldr("地理B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") 怎么上述代码与下面代码执行结果不一样?请指教。谢谢! Dim km1s() As String = {"语文","数学","英语","物理","化学","生物","政治","历史","地理"} For Each km1 As String In km1s dr(km1 & "有效分/人数") = DataTables("成绩库").Compute("count(单位)", " \'" & km1 & "\' >= \'" & ldr(km1 & "B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") Next |
-- 作者:有点蓝 -- 发布时间:2019/11/25 11:34:00 -- For Each km1 As String In km1s dr(km1 & "有效分/人数") = DataTables("成绩库").Compute("count(单位)", km1 & " >= \'" & ldr(km1 & "B") & "\' And 总分 >= \'" & ldr("总分B") & "\' And [部别] = \'" & dr("部别") & "\' And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") Next
|
-- 作者:cqlpjks -- 发布时间:2019/11/25 13:47:00 -- 谢谢! dr(km1 & "平均分") = DataTables("成绩库").Compute("Avg(语文)", " [单位] = \'" & dr("单位") & "\'and [班] = \'" & dr("班") & "\'and [部别] = \'" & dr("部别") & "\'And [年级] = \'" & dr("年级") & "\' And [类别] = \'" & dr("类别") & "\'") “语文”是变量“km1”,如何表示"Avg(语文)"?请指教。谢谢!
|
-- 作者:有点蓝 -- 发布时间:2019/11/25 14:04:00 -- dr(km1 & "平均分") = DataTables("成绩库").Compute("Avg(" & km1 & ")", " [单位] |
-- 作者:cqlpjks -- 发布时间:2019/11/25 14:16:00 -- 谢谢! |