Dim yh As String = args(0)
Dim lst As List(of String) = args(1)
Dim level As Integer = args(2)
Dim drs As List(Of DataRow) = DataTables("表A").Select("推荐人用户名='" & yh & "'")
If drs.Count = 0 Then Return level
Dim k As Integer
For Each dr As DataRow In drs
If dr.IsNull("用户证件号") Then
lst(0) = val(lst(0)) + 1
Else
If lst.Contains(dr("用户证件号")) = False
lst.Add(dr("用户证件号"))
End If
k = Functions.Execute("sumchild",dr("用户名"),lst,level+1)
If k > level Then level = k
End If
Next
Return level
命令窗口调用
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("用户名", Gettype(String), 32)
dtb.AddDef("层次", Gettype(Integer))
dtb.AddDef("计数", Gettype(Integer))
dtb.Build()
MainTable= Tables("统计")
Dim lst As New List(of String)
For Each yh As String In DataTables("表A").GetValues("用户名")
lst.Clear
lst.Add("0")
Dim k = Functions.Execute("sumchild",yh,lst,0)
If k>=3 AndAlso (val(lst(0)) + lst.Count-1) >= 30
Dim r As Row = Tables("统计").AddNew
r("用户名") = yh
r("层次") = k
r("计数") = val(lst(0)) + lst.Count-1
End If
Next