Foxtable(狐表)用户栏目专家坐堂 → [求助][求助]建表问题二


  共有3236人关注过本帖树形打印复制链接

主题:[求助][求助]建表问题二

帅哥哟,离线,有人找我吗?
cqlpjks
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:407 积分:3194 威望:0 精华:0 注册:2011/2/28 11:57:00
[求助][求助]建表问题二  发帖心情 Post By: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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:407 积分:3194 威望:0 精华:0 注册:2011/2/28 11:57:00
  发帖心情 Post By: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

 回到顶部