For example, the following code is a custom function to calculate factorial. The code is as follows:
Function jc(a is an integer)
If a>, then 50
jc = 0
Exit function
If ... it will be over.
jc = 1
For I = 1 to a
jc = jc * I
Next, I
End function
Jc here can also be understood as a variable with an initial value of = 1, and the required factorial value can be obtained by multiplication.
You can see how jc changes by running it in a single step.
Set a breakpoint at jc=jc*i, as shown in the figure:
When a= 10, check that the function is running.
Step 1: Check the values of variables I and JC when i= 1. As shown in the figure:
Step 2: Look at the values of variables I and JC when i=2. As shown in the figure:
Step 3: Check the values of variables I and JC when i=5. As shown in the figure:
Step 4: Check the values of variables I and JC when i=5. As shown in the figure: