Dim cmd As new SQLCommand
Dim Sqldt As DataTable
cmd.C
cmd.CommandText = "Sel ect * From {部门} Where [上级部门] = '" & args(0) & "'"
Dim lm As String = args(1)
Sqldt = cmd.ExecuteReader
If Sqldt.DataRows.Count > 0 Then
For Each dr As DataRow In sqldt.DataRows
If lm > "" Then LM &= "|"
lm &= dr("部门名称")
Dim val As Integer
cmd.CommandText = "Sele ct Count(*) From {部门} Where [上级部门] = '" & dr("部门名称") & "'"
val = cmd.ExecuteScalar()
If val > 0 Then Functions.Execute("部门查找递归",dr("部门名称"),lm)
Next
End If
Return lm
MessageBox.Show(Functions.Execute("部门查找递归","总裁办","总裁办"))
代码如上,红色字运行后得到的LM变量,没办法传递回原来的LM变量
如总裁办下属有生产部|销售部|财务部,生产部下属有工程部, 最终得到的结果只有生产部|销售部|财务部,而不是生产部|销售部|财务部|工程部