目的:通过递归算法实现子节点对应表中行的数值列的累计计算,但出现了系统错误,说明如下:
1. 数据源

2. 命令窗口的程序代码
Forms("Win1").open()
Dim tr As WinForm.TreeView = Forms("Win1").Controls("TreeView1")
Dim tb As Table = Tables("TbTree")
tr.GenerateTree(DataTables("TbTree"),"Cod","ValueA",".") '显示ValueA,用与于程序结果核对
Forms("Win1").show()
For Each nd As WinForm.TreeNode In tr.nodes
If nd.nodes.Count = 0 Then
nd.ParentNode.DataRow("ValueA")+=nd.DataRow("ValueA")
nd.ParentNode.DataRow("ValueB")+=nd.DataRow("ValueB")
Else
Functions.Execute("CalChild",tb,tr,nd)
nd.ParentNode.DataRow("ValueA")+=nd.DataRow("ValueA")
nd.ParentNode.DataRow("ValueB")+=nd.DataRow("ValueB")
End If
Next
3. 内部函数代码
Dim tb As Table = args(0)
Dim tr As WinForm.TreeView = args(1)
Dim nd As WinForm.TreeNode = args(2)
For Each ndcd As WinForm.TreeNode In nd.nodes
If ndcd.nodes.count=0 Then
ndcd.ParentNode.DataRow("ValueA")+=ndcd.DataRow("ValueA")
ndcd.ParentNode.DataRow("ValueB")+=ndcd.DataRow("ValueB")
Else
Functions.Execute("CalChild",tb,tr,ndcd)
ndcd.ParentNode.DataRow("ValueA")+=ndcd.DataRow("ValueA")
ndcd.ParentNode.DataRow("ValueB")+=ndcd.DataRow("ValueB")
End If
Next
4. 显示结果及未知的系统错误
系统错误

但仍然能显示结果:


??请大师指点,改正错误??