For n As Integer = tbl.Rows.Count - 1 To 0 Step - 1 \'n为整数,从下往上遍历
Dim cr As Row = tbl.Rows(n) \'定义cr为行,下级行
Dim cHierarchy As Integer = cr.Hierarchy \'下级行层级
For m As Integer = n - 1 To 0 Step - 1 \'同样从下往上遍历,找出父行
Dim pr As Row = tbl.Rows(m)
Dim pHierarchy As Integer = pr.Hierarchy \'
If cr.Hierarchy = pHierarchy + 1 Then \'如果是父行
cr("成本测算_收益金额") = cr("中标清单_合价不含增值税") - cr("成本测算_合价")\'计算收益金额
cr("成本测算_收益率") = cr("成本测算_收益金额") / cr("中标清单_合价不含增值税") \'计算收益率
Exit For
End If
Next
Next