以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  横表转纵表  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=82453)

--  作者:kaituozhe
--  发布时间:2016/3/17 23:03:00
--  横表转纵表
以下代码是中余额横表已审中列是会计科目名称,已审综合资产负债表是纵表,以下代码中如果注释掉的代码不使用完全可以执行,但是这样类似是黄色的代码需要一个一个写,想通过循环来实现,也就是红色代码,但是红色代码执行时没有任何效果,是什么原因?
Dim tb As DataTable = DataTables("已审综合资产负债表")
Dim tb1 As DataTable = DataTables("余额横表已审")
Dim nms As List (of String) = DataTables("会计科目").GetValues("资产负债表","资产负债表 is not null")
If e.DataCol.name = "资产" Then
        \'For Each nm As String In nms
        \'\'msgbox(nm)
        \'If DataTables("会计科目").find("资产负债表 = \'" & nm & "\'")("资产负债表包含科目") Is Nothing Then
        \'\'tb.find("资产= \'" & nm & "\'")("资产2015年期初数") = tb1.Compute("sum(nm)","会计年度 = \'2014\'")
        tb.find("资产= \'交易性金融资产\'")("资产2015年期初数") = tb1.Compute("sum(交易性金融资产)","会计年度 = \'2014\'")
        \'msgbox(1)
        tb.find("资产= \'货币资金\'")("资产2015年期初数") = tb1.Compute("sum(库存现金)","会计年度 = \'2014\'")+tb1.Compute("sum(银行存款)","会计年度 = \'2014\'")+tb1.Compute("sum(其他货币资金)","会计年度 = \'2014\'")
        \'End If
    \'Next
End If

--  作者:大红袍
--  发布时间:2016/3/17 23:16:00
--  
tb.find("资产= \'" & nm & "\'")("资产2015年期初数") = tb1.Compute("sum(" & nm & ")","会计年度 = \'2014\'")
--  作者:kaituozhe
--  发布时间:2016/3/17 23:27:00
--  
按2楼的改了还是不行呀,郁闷!
Dim tb As DataTable = DataTables("已审综合资产负债表")
Dim tb1 As DataTable = DataTables("余额横表已审")
Dim nms As List (of String) = DataTables("会计科目").GetValues("资产负债表","资产负债表 is not null")
If e.DataCol.name = "资产" Then
    For Each nm As String In nms
        If DataTables("会计科目").find("资产负债表 = \'" & nm & "\'")("资产负债表包含科目") Is Nothing Then
            \'tb.find("资产= \'" & nm & "\'")("资产2015年期初数") = tb1.Compute("sum(" & nm & ")","会计年度 = \'2014\'")
            tb.find("资产= \'" & nm & "\'")("资产2015年期初数") = tb1.Compute("sum(" & nm & ")","会计年度 = \'2014\'")
            \'tb.find("资产= \'交易性金融资产\'")("资产2015年期初数") = tb1.Compute("sum(交易性金融资产)","会计年度 = \'2014\'")
            \'tb.find("资产= \'货币资金\'")("资产2015年期初数") = tb1.Compute("sum(库存现金)","会计年度 = \'2014\'")+tb1.Compute("sum(银行存款)","会计年度 = \'2014\'")+tb1.Compute("sum(其他货币资金)","会计年度 = \'2014\'")
        End If
    Next
End If

--  作者:狐狸爸爸
--  发布时间:2016/3/18 8:17:00
--  

1、你上面的计算代码全部注释了,是否因为这个原因?

2、如果你实际的代码没有注释,你可以在关键位置加一个MessageBox,看看计算代码是否执行了。

3、即使代码完全正确,你也要修改资产列才会生效,对于已经输入的数据,需要重置资产列:

 

看看表事件的入门:

http://www.foxtable.com/help/topics/1469.htm

http://www.foxtable.com/help/topics/1587.htm