以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  求某一列环比值的计算代码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=17927)

--  作者:狐狸爸爸
--  发布时间:2012/3/29 8:07:00
--  
If e.DataCol.Name="第一列" AndAlso e.NewValue > 0  Then
    Dim dr1 As DataRow = e.DataRow
    Dim dr2 As DataRow = e.DataTable.Find("日期 < #" & e.DataRow("日期") & "#","日期 Desc")
    If dr2 Is Nothing Then
        dr1("环比") = 0
    Else
        dr1("环比") = (dr1("第一列") - dr2("第一列")) / dr1("第一列")
    End If
End If