You must jump out of the nested for loop in time. Otherwise, you may encounter an inexplicable problem, just as I did at the beginning:
Write an online color purchase program. After you select the value of the check box on the Color purchase page, the program generates and outputs the possible number of notes based on these values.
For each B in Iddi
For each C in iddii
For each d in iddiii
For each E in iddiv
For each F in iddv
For each G in iddvi
For each h in iddvii
'If B = "" then
'Response. Write ("the number of data digits is incomplete. Please reselect ")
'Response. End ()
'End if
If caizhong = "3D" or caizhong = "3" then
N = trim (B) & trim (c) & trim (d)
STR = STR & N & "& nbsp ;"
Elseif caizhong = "arrange 5" then
N = trim (B) & trim (c) & trim (d) & trim (e) & trim (f)
STR = STR & N & "& nbsp ;"
Elseif caizhong = "" then
N = trim (B) & trim (c) & trim (d) & trim (e) & trim (f) & trim (g) & trim (h)
STR = STR & N & "& nbsp ;"
End if
Next
Next
Next
Next
Next
Next
Next
The output is
<% = STR %>
It is strange that the output is normal only when caizhong = "", and the STR value is empty in other cases. Who knows what's going on? Help me. Thank you.
I tried to explain it everywhere. I was about to hit the wall when I was depressed. Finally, when I checked the for loop, I saw the statement exit for jumping out of the loop. I thought, is there no reason to jump out of the loop? Modify the program to the following code:
For each B in Iddi
For each C in iddii
For each d in iddiii
If caizhong = "3D" or caizhong = "3" then
N = trim (B) & trim (c) & trim (d)
STR = STR & N & "& nbsp ;"
Exit
End if
For each E in iddiv
For each F in iddv
If caizhong = "arrange 5" then
N = trim (B) & trim (c) & trim (d) & trim (e) & trim (f)
STR = STR & N & "& nbsp ;"
Exit
End if
For each G in iddvi
For each h in iddvii
If caizhong = "" then
N = trim (B) & trim (c) & trim (d) & trim (e) & trim (f) & trim (g) & trim (h)
STR = STR & N & "& nbsp ;"
End if
Next
Next
Next
Next
Next
Next
Next
Save and run. Haha, I am so excited that I have finally shown what I mean.
You should be careful when using for loop nesting later.