iSum = 0
For iCnt = 1 to 5
iSum = iSum + iCnt
If iCnt = 5 then iSum = 200
![]() |
iSum = 0
For iCnt = 1 to 5
iSum = iSum + iCnt
If iCnt = 5 then iSum = 200
First, you need a Next statement.
Sum = 0
For iCnt = 1 to 5
iSum = iSum + iCnt
Next iCnt
If iCnt = 5 then iSum = 200
iCnt is incremented at the end of each loop (that's when the comparison is made that ends the loop), so when the FOR loop ends, the value of iCnt will be 6.
iSum will be 15 (1 + 2 + 3 + 4 + 5)
All times are GMT -7. The time now is 02:05 PM. |