判断一下
......
For Each ndcd As WinForm.TreeNode In nd.nodes
if ndcd.ParentNode isnot nothing then
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
end if
Next