Loops, a basic question of performance
Having this as refrence:
VB Code:
Dim i as integer
For i=0 to 1000
'Some code here
Next
Which one of the following will run faster? any as fast as the above?
1:
VB Code:
Dim i as Integer, J as Integer=1000
For i=0 to J
'Some code with no change in J value
Next
2:
VB Code:
Dim i as Integer, J as Integer=2000
For i=0 to J/2 ' Or any other operation on J
'Some code with no change in J value
Next
3:
VB Code:
Dim i as Integer
Const J as Integer=1000
For i=0 to J
'Some code with no change in J value
Next
4:
VB Code:
Dim i as Integer
Const J as Integer=2000
For i=0 to J/2 'or any other operation on J
'Some code with no change in J value
Next