can function call it self then how explain
can function call it self then how explain
Collapse
X
-
Here's a basic example I snatched from a helpfile in MSAccess. Just adapt the concept to your code. Watch the output; it climbs up through the repeated function calls, then backs back down when it hits a certain condition. Step through it to fully understand the action & results of your variables.
Code:Function Factorial(N) If N <= 1 Then ' Reached end of recursive calls. Factorial = 1 ' (N = 0) so climb back out of calls. Else ' Call Factorial again if N > 0. Debug.Print "FuncN =" & N Factorial = Factorial(N - 1) * N End If End FunctionComment
Comment