Foxtable(狐表)用户栏目专家坐堂 → 基础问题


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

主题:基础问题

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/18 12:30:00 [显示全部帖子]

Dim r As Row = Tables("表A").current
Dim skdt As DataTable = r.Table.DataTable
Dim sksumlwg As Double
Dim sksumgyg As Double
For Each skdc As DataCol In skdt.DataCols
    Select Case skdc.name
        Case "Lwg12","Lwg16","Lwg18","Lwg20","Lwg22","Lwg25","Lwg28","Lwg32"
            sksumlwg = sksumlwg + r(skdc.name)
        Case "Gyg12","Gyg10","Gyg8","Gyg6"
            sksumgyg = sksumgyg + r(skdc.name)
    End Select
Next
r("Lwg") = sksumlwg
r("Gyg") = sksumgyg

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/18 14:29:00 [显示全部帖子]

Dim r As Row = Tables("表A").current

 

改成

 

Dim r As Row = currentTable.current


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/18 15:52:00 [显示全部帖子]

Dim skdt As DataTable = DataTables("表A")
For Each r As DataRow In skdt.Select("")
    Dim sksumlwg As Double = 0
    Dim sksumgyg As Double = 0
    For Each skdc As DataCol In skdt.DataCols
        Select Case skdc.name
            Case "Lwg12","Lwg16","Lwg18","Lwg20","Lwg22","Lwg25","Lwg28","Lwg32"
                sksumlwg = sksumlwg + r(skdc.name)
            Case "Gyg12","Gyg10","Gyg8","Gyg6"
                sksumgyg = sksumgyg + r(skdc.name)
        End Select
    Next
    r("Lwg") = sksumlwg
    r("Gyg") = sksumgyg
Next

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/18 17:33:00 [显示全部帖子]

如果多个表一起执行,改成下面,如果运算当前表,改成 Dim skdt As DataTable =currenttable.DataTable

 

Dim dts() As String = {"表A", "表B", "表C"}
For Each s As String In dts
    Dim skdt As DataTable = DataTables(s)
    For Each r As DataRow In skdt.Select("")
        Dim sksumlwg As Double = 0
        Dim sksumgyg As Double = 0
        For Each skdc As DataCol In skdt.DataCols
            Select Case skdc.name
                Case "Lwg12","Lwg16","Lwg18","Lwg20","Lwg22","Lwg25","Lwg28","Lwg32"
                    sksumlwg = sksumlwg + r(skdc.name)
                Case "Gyg12","Gyg10","Gyg8","Gyg6"
                    sksumgyg = sksumgyg + r(skdc.name)
            End Select
        Next
        r("Lwg") = sksumlwg
        r("Gyg") = sksumgyg
    Next
Next


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/19 16:01:00 [显示全部帖子]


 回到顶部