Is there a difference between these?
For i = 0 To Something.Length - 1
'do something
Next
For i = 0 To Something.Length - 1
'do something
Next i
You use a For ... Next structure when you want to repeat a set of statements a set number of times. In the following example, the index variable starts with a value of 1 and is incremented with each iteration of the loop, ending after the value of index reaches 5.
The for... next statement is an iterative, incremental loop statement used to repeat a sequence of statements for a specific number of occurrences. A for... next loop executes a set of statements for successive values of a variable until a limiting value is encountered.
It is only for readability:
You can optionally specify counter in the Next statement. This improves the readability of your program, especially if you have nested For loops. You must specify the same variable as the one that appears in the corresponding For statement.
From http://msdn.microsoft.com/en-us/library/5z06z1kb.aspx
Nope. There is no difference. Even with nested loops there is no difference because nested for-loops cannot overlap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With