以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助][求助]建表问题二  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=142950)

--  作者:cqlpjks
--  发布时间:2019/11/9 20:21:00
--  [求助][求助]建表问题二
Dim Values() As String = {"总分"}
Dim s1() As String = New String() {"总分"}
Dim dt As Table = Tables("成绩库")
StatusBar.Message1= "正在生成统计数据"
For Each Value As String In Values
    Dim nj As String = e.Form.Controls("年级").text \'统计年级
    Dim tjlb As String = e.Form.Controls("类别").text \'统计类别
    Dim bm As String = Value & "重点人数对照表"
    Dim dtb As New DataTableBuilder(bm)
    dtb.AddDef("单位",Gettype(String),8)
    dtb.AddDef("统计类别",Gettype(String),8)
    For Each tjbb As String In DataTables("成绩库").GetValues("部别","[年级] = \'" & nj & "\'And [类别] = \'"& tjlb &"\'")
        Dim c1 As Double = nj
        Dim c2 As Double = nj-1
        Dim c3 As Double = nj-2
        Dim tjnjs() As String = {"" & c3 &" ","" & c2 & "","" & c1 & ""}
        For Each tjnj As String In tjnjs
            dtb.AddDef( tjbb & tjnj &"",Gettype(Double),"",tjbb &"_"& tjnj & "级")
            dtb.AddDef( "合计"& tjnj &"",Gettype(Double),"","合  计_"& tjnj & "级")            
            dtb.Build()
        Next
    Next
Next
\'e.Form.Controls("Label1").text ="统计结束,请导出数据!否则数据会丢失!"
StatusBar.Reset
StatusBar.DefaultMessage = "统计完毕!"
\'Time1 = Date.Now
\'e.Form.Controls("Label4").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"
Tables("成绩库").ResumeRedraw


错误提示:名为“合计2018 ”的列已属于此 DataTable。

注:统计年级nj的值是 2020
  部别tjbb的值是       高文、高理

统计结果应为:
图片点击可在新窗口打开查看此主题相关图片如下:结果应为.png
图片点击可在新窗口打开查看

红色部分代码如何修改?请指教。谢谢!
[此贴子已经被作者于2019/11/10 8:23:22编辑过]

--  作者:cqlpjks
--  发布时间:2019/11/10 16:43:00
--  
已经解决。
Dim Values() As String = {"总分"}
Dim s1() As String = New String() {"总分"}
Dim dt As Table = Tables("成绩库")
For Each Value As String In Values
    Dim tjlb As String = e.Form.Controls("类别").text \'统计类别
    Dim nj As String = e.Form.Controls("年级").text \'统计年级
    Dim bm As String = Value & "重点人数对照表"
    Dim dtb As New DataTableBuilder(bm)
    dtb.AddDef("单位",Gettype(String),8)
    dtb.AddDef("统计类别",Gettype(String),8)
    For Each tjbb As String In DataTables("成绩库").GetValues("部别","[年级] = \'" & nj & "\'And [类别] = \'"& tjlb &"\'")
        For i As Integer = 0 To 2
            dtb.AddDef( tjbb & i ,Gettype(Double),"",tjbb &"_"& (nj-i) & "级")
        Next
    Next
    For i As Integer = 0 To 2
        dtb.AddDef("合计"& i ,Gettype(Double),"","合  计_"& (nj-i) & "级")
    Next
    dtb.Build()
Next
StatusBar.Reset
Tables("成绩库").ResumeRedraw