vb过程调用

来源:百度知道 编辑:UC知道 时间:2024/05/29 20:00:53
CODE:
private sub command1_click()
print Test(3)
End Sub
private Function Test(t as integer) as Intger
Dim i as integer
If t>=1 Then
Call Test(t-1)
For i=3 to t step -1
print Chr(Asc("A")+i)
next i
print
End if
text=t
end Function
窗体显示 DCB
DC
D
3
过程怎么可以自己调用自己的啊!Call Test(t-1)后是继续执行下面的还是回到function啊??哪位高手帮忙指点啊!
递归好像是到t=0才不满足条件吧,这样的话打印出来的就是DCBA吗??高手指点啊!!

Public Function Test(t As Integer) As Integer
Dim i As Integer
If t >= 1 Then
Call Test(t - 1)
For i = 3 To t Step -1
Print Chr(Asc("A") + i)
Next i
Print
End If
Text = t
End Function
其中:Call Test(t - 1)就是自已调用自己
Call Test(t - 1)后是首先又调用了函数本身,直到If t >= 1 Then这个条件不满足之后才结束递归,才继续往下走

这是递归,好好看看递归方面的知识