以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  基础问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=122061)

--  作者:wuchangke4
--  发布时间:2018/7/18 11:55:00
--  基础问题
现在我每个表都用到如下统计代码,想用菜单代替,但对e参数不是很熟,如何将表事件代码转为标准按钮代码?

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


--  作者:有点甜
--  发布时间: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

--  作者:wuchangke4
--  发布时间:2018/7/18 14:17:00
--  
Dim r As Row = Tables("表A").current
这一句是否有了局限,如果一个项目里有十个表需要用这个功能组件呢?

--  作者:有点甜
--  发布时间:2018/7/18 14:29:00
--  

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

 

改成

 

Dim r As Row = currentTable.current


--  作者:wuchangke4
--  发布时间:2018/7/18 14:48:00
--  
如果需要列Lwg和列Gy一次性完成整列统计,不要一行一行的,可以实现吗?
--  作者:有点甜
--  发布时间: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

--  作者:wuchangke4
--  发布时间:2018/7/18 16:06:00
--  
Dim skdt As DataTable = DataTables("表A")
这个表A是否又具有局限性了?

--  作者:wuchangke4
--  发布时间:2018/7/18 16:54:00
--  

Dim skdt As DataTable = DataTables("表A")改为


 Dim skdt As DataTable =currenttable.DataTable 
会有影响吗?

--  作者:有点甜
--  发布时间: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


--  作者:wuchangke4
--  发布时间:2018/7/19 14:49:00
--  
 如果要实现当右击Lwg或Gyg这两列中的任意一列的单元格时,显示快捷菜单,如何设置代码?