Select e.DataCol.Name
Case "数量","日期"
Dim dr1 As DataRow = e.DataRow
'本日期的行
Dim dr2
As DataRow =
e.DataTable.Find("日期 < #"
&
e.DataRow("日期") &
"#","日期 Desc") '前一日期的行
Dim dr3
As DataRow =
e.DataTable.Find("日期 > #"
&
e.DataRow("日期") &
"#","日期") '下一日期的行
If dr2
Is Nothing Then
dr1("环比") = 0
ElseIf dr2("数量") > 0
dr1("环比") = (dr1("数量") - dr2("数量")) / dr2("数量")
Else
dr1("环比") =
Nothing
End If
If dr3 IsNot Nothing
If dr1("数量") > 0 Then
dr3("环比") = (dr3("数量") - dr1("数量")) / dr1("数量")
Else
dr3("环比") =
Nothing
End If
End If
End Select
这段程序是帮助里的“编码计算环比”程序,现在新建个窗口1,放置一个按钮和一个表控件,将这段程序放到按钮事件里,如何才能正常运行计算?