Hi all,
I have a for loop that doesn't behave how I expect, and I was hoping someone could explain it for me...
I would expect the following loop to run exactly 1 time
It runs two times for me.
I starts as 0, and runs through the loop to next i, where it gets incremented to 1. Now it comes to the top, evaluates that it is less than (times -1) and should not go through the loop again.
Where is my mistake in understanding how a for loop works?
Thanks for your help,
CJB
I have a for loop that doesn't behave how I expect, and I was hoping someone could explain it for me...
I would expect the following loop to run exactly 1 time
Code:
dim times as integer = 2
dim i as integer = 0
for i = 0 to (times - 1)
response.write("i is:" + i.toString + " ")
times -= 1
next i
It runs two times for me.
I starts as 0, and runs through the loop to next i, where it gets incremented to 1. Now it comes to the top, evaluates that it is less than (times -1) and should not go through the loop again.
Where is my mistake in understanding how a for loop works?
Thanks for your help,
CJB