以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]代码简化 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=160758) |
-- 作者:cqlpjks -- 发布时间:2021/2/20 14:15:00 -- [求助]代码简化 Dim fhs() As String = {"德","能","勤","绩","廉"} Dim pj2s() As String = {"好","较好","一般","差"} Dim djs() As String = {"A","B","C","D"} Dim dlqjs() As String = {"题号1","题号2","题号3","题号4","题号5"} For Each fh As String In fhs For Each dlqj As String In dlqjs For i As Integer = 1 To 5 For j As Integer = 0 To djs.length - 1 dr("德" & djs(j) & "人") = DataTables("答案1").Compute("Count("& dr("题号1") &")", "" & dr("题号1") & " = \'"& djs(j) &"\' And [单位] = \'" & dr("单位") & "\'") dr("能" & djs(j) & "人") = DataTables("答案1").Compute("Count("& dr("题号2") &")", "" & dr("题号2") & " = \'"& djs(j) &"\' And [单位] = \'" & dr("单位") & "\'") dr("勤" & djs(j) & "人") = DataTables("答案1").Compute("Count("& dr("题号3") &")", "" & dr("题号3") & " = \'"& djs(j) &"\' And [单位] = \'" & dr("单位") & "\'") dr("绩" & djs(j) & "人") = DataTables("答案1").Compute("Count("& dr("题号4") &")", "" & dr("题号4") & " = \'"& djs(j) &"\' And [单位] = \'" & dr("单位") & "\'") dr("廉" & djs(j) & "人") = DataTables("答案1").Compute("Count("& dr("题号5") &")", "" & dr("题号5") & " = \'"& djs(j) &"\' And [单位] = \'" & dr("单位") & "\'") Next Next Next Next 红色代码简化成: dr(fh & djs(j) & "人") = DataTables("答案1").Compute("Count("& dr(dlqjs(j)) &")", "" & dr(dlqjs(j)) & " = \'"& djs(j) &"\' And [单位] = \'" & dr("单位") & "\'") 统计结果全是最后一个红色代码dr("廉" & djs(j) & "人") = DataTables("答案1").Compute("Count("& dr("题号5") &")", "" & dr("题号5") & " = \'"& djs(j) &"\' And [单位] = \'" & dr("单位") & "\'")的结果。 [此贴子已经被作者于2021/2/20 14:27:03编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/2/20 14:30:00 -- Dim fhs() As String = {"德","能","勤","绩","廉"} Dim pj2s() As String = {"好","较好","一般","差"} Dim djs() As String = {"A","B","C","D"} Dim dlqjs() As String = {"题号1","题号2","题号3","题号4","题号5"} For i As Integer = 0 To fhs.length - 1 For j As Integer = 0 To djs.length - 1 dr(fhs(i) & djs(j) & "人") = DataTables("答案1").Compute("Count("& dr(dlqjs(i)) &")", "" & dr(dlqjs(i)) & " = \'"& djs(j) &"\' And [单位] = \'" & dr("单位") & "\'") Next Next |
-- 作者:cqlpjks -- 发布时间:2021/2/20 16:33:00 -- 谢谢! |