Foxtable(狐表)用户栏目专家坐堂 → [求助]还是代码简化


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

主题:[求助]还是代码简化

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


加好友 发短信
等级:一尾狐 帖子:407 积分:3194 威望:0 精华:0 注册:2011/2/28 11:57:00
[求助]还是代码简化  发帖心情 Post By:2021/2/22 22:20:00 [只看该作者]

Dim Values() As String = {"总分"}
Dim s1() As String = New String() {"总分"}
Dim dt As Table = Tables("成绩库")
Dim lm1s() As String = {"序号","部别","年级","科目"}
Dim lm2s() As String = {"参考人数","平均分","标准差"}
Dim dhs() As String = {"重点A","本科A","专科A"}
Dim lm3s() As String = {"平均分","标准差","平均分之和","标准差之和","目标","重点线","有效分"}
Dim tjnj As String = 2018
For Each Value As String In Values
    Dim dtb As New DataTableBuilder( value & tjnj &  "级有效分")
    For Each lm1 As String In lm1s
        dtb.AddDef( lm1 ,Gettype(String),8)
    Next
    For Each lm2 As String In lm2s
        dtb.AddDef( lm2 ,Gettype(Double))
    Next
    For Each lm3 As String In lm3s
        For Each dh As String In dhs
            For i As Integer = 1 To 7
                dtb.AddDef( dh & i ,Gettype(Double),"", dh & "_ "& lm3 &"")
            Next
        Next
    Next
    dtb.Build()
Next
执行代码报错:

图片点击可在新窗口打开查看此主题相关图片如下:报错.png
图片点击可在新窗口打开查看

红色部分代码是下面代码的简化:
dtb.AddDef("重点A1",Gettype(Double),"","重点A及以上_平均分")
dtb.AddDef("重点A2",Gettype(Double),"","重点A及以上_标准差")
dtb.AddDef("重点A3",Gettype(Double),"","重点A及以上_平均分之和")
dtb.AddDef("重点A4",Gettype(Double),"","重点A及以上_标准差之和")
dtb.AddDef("重点A5",Gettype(Double),"","重点A及以上_目标")
dtb.AddDef("重点A6",Gettype(Double),"","重点A及以上_重点线")
dtb.AddDef("重点A7",Gettype(Double),"","重点A及以上_有效分")
dtb.AddDef("本科A1",Gettype(Double),"","本科A及以上_平均分")
dtb.AddDef("本科A2",Gettype(Double),"","本科A及以上_标准差")
dtb.AddDef("本科A3",Gettype(Double),"","本科A及以上_平均分之和")
dtb.AddDef("本科A4",Gettype(Double),"","本科A及以上_标准差之和")
dtb.AddDef("本科A5",Gettype(Double),"","本科A及以上_目标")
dtb.AddDef("本科A6",Gettype(Double),"","本科A及以上_本科线")
dtb.AddDef("本科A7",Gettype(Double),"","本科A及以上_有效分")
dtb.AddDef("专科A1",Gettype(Double),"","专科A及以上_平均分")
dtb.AddDef("专科A2",Gettype(Double),"","专科A及以上_标准差")
dtb.AddDef("专科A3",Gettype(Double),"","专科A及以上_平均分之和")
dtb.AddDef("专科A4",Gettype(Double),"","专科A及以上_标准差之和")
dtb.AddDef("专科A5",Gettype(Double),"","专科A及以上_目标")
dtb.AddDef("专科A6",Gettype(Double),"","专科A及以上_专科线")
dtb.AddDef("专科A7",Gettype(Double),"","专科A及以上_有效分")
建表样式:

图片点击可在新窗口打开查看此主题相关图片如下:有效分样式.png
图片点击可在新窗口打开查看
如何修改红色部分代码?请指教,谢谢!


[此贴子已经被作者于2021/2/22 22:26:23编辑过]

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


加好友 发短信
等级:一尾狐 帖子:407 积分:3194 威望:0 精华:0 注册:2011/2/28 11:57:00
  发帖心情 Post By:2021/2/22 22:35:00 [只看该作者]

解决了。谢谢!
dtb.AddDef( dh & lm3 ,Gettype(Double),"", dh & "及以上_ "& lm3 &"")

 回到顶部
帅哥,在线噢!
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110736 积分:563600 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/2/22 22:40:00 [只看该作者]

Dim dtb As New DataTableBuilder("总分2018级有效分")
Dim lm1s() As String = {"序号","部别","年级","科目","参考人数","平均分","标准差"}
    For Each lm1 As String In lm1s
        dtb.AddDef( lm1 ,Gettype(String),8)
    Next
Dim dhs() As String = {"重点A","本科A","专科A"}
Dim lm3s() As String = {"平均分","标准差","平均分之和","标准差之和","目标","重点线","有效分"}
For Each dh As String In dhs
    For i As Integer = 0 To lm3s.length - 1
        dtb.AddDef( dh & (i+1) ,Gettype(Double),"", dh & "及以上_" & lm3s(i))
    Next
Next
dtb.Build()

 回到顶部