Dim tb As DataTable = DataTables("基本情况")
Dim nms As new List (of String )
For y As Integer = CDate(tb.find("项目= '开始日期'")("内容")).Year To CDate(tb.find("项目= '截止日期'")("内容")).Year
nms.Add(y)
Next
kuaijiqijian = nms
以上代码建立项目时提取基本情况表中年度形成集合nms 但是建立项目完成后怎么能在打开项目时自动把nms传递给nms 并把数据放在kuaijiqijian是全局变量中,让科目表或其他表引用, 以下代码是科目表的datacolchanged中的代码
Dim nms As new List (of String)
msgbox(1)
nms= kuaijiqijian
msgbox(2)
Select Case e.DataCol.name
Case "会计科目"
If e.NewValue IsNot Nothing Then
msgbox(nms)
If nms.count = 1 Then
msgbox("余额" & nms(0) & "年_期初余额")
Dim str0 As String = "余额" & nms(0) & "年_期初余额"
e.DataRow("余额" & nms(0) & "年_期末余额") = e.DataRow("余额" & nms(0) & "年_期初余额") +e.DataRow("余额" & nms(0) & "年_借方发生")-e.DataRow("余额" & nms(0) & "年_贷方发生")
ElseIf nms.count> 1 Then
e.DataRow("余额" & nms(0) & "年_期末余额") = e.DataRow("余额" & nms(0) & "年_期初余额") +e.DataRow("余额" & nms(0) & "年_借方发生")-e.DataRow("余额" & nms(0) & "年_贷方发生")
For n As Integer = 1 To nms.count-1
Dim str1 As String = "余额" & nms(n) & "年_期末余额"
Dim str2 As String = "余额" & nms(n) & "年_借方发生"
Dim str3 As String = "余额" & nms(n) & "年_贷方发生"
Dim str4 As String = "余额" & nms(n-1) & "年_期末余额"
e.DataRow(str1) = e.DataRow(str4)+e.DataRow(str2) -e.DataRow(str3)
Next
End If
End If
End Select