1、在内部函数中新建一个函数,名为AddChildren,代码为:
Dim nd As WinForm.TreeNode = args(0)Dim dt As DataTable = args(1)For Each dr As DataRow In dt.Select("","科目代码") Dim km As String = dr("科目代码") If km.StartsWith(nd.name) AndAlso km.Length = nd.Name.Length + 2 Then Dim cd As Winform.TreeNode = nd.Nodes.Add(km,km & " " & dr("科目名称")) Functions.Execute("AddChildren",cd,dt) End IfNext
上述代码中,出现了调用AddChildren函数自身的代码(第8行):
Functions.Execute("AddChildren",cd,dt)