Dim nms() As String = {"a","b"} For Each r As DataRow In DataTables("员工信息表").DataRows For Each nm As String In nms Dim cnt As Integer = 0 Dim tr As DataRow = r Do If tr.IsNull("下级_" & nm) = False Then cnt = cnt + 1 tr = DataTables("员工信息表").Find("会员编号 = '" & tr("下级_" & nm) & "'") If tr Is Nothing Then Exit Do End If Else Exit Do End If Loop r("累积_" & nm) = cnt Next Next