VB.Net - FOR loop, using a variable iteration?

Started by
2 comments, last by alexmoura 15 years, 2 months ago
Wanna do something like this for example: if xyz > 0 then y = 1 else y = -1 end if for x = 0 to xyz +y So in other words I want to be able to specify the iteration. I remember being able to do something similar, probably with c or c++. Can this be done in vb.net 08? If so please show syntax, as I have tried everything obvious and I am using express without MSDN. No luck with google as all the search terms are commonly used.. TIA
Advertisement
A for loop requires a block and there should be some statement inside of it.

for x = 0 to (xyz+y)  ' Do something herenext x


You can't just put "for x = 0 to xyz +y" and expect it to do anything.
Yeah i know.

Im talking about specifying the iteration.

By default, it increments x by 1 each time it loops

I think I may have found it..

Is this example correct for looping backwards?

for x = 0 to -10 step -1

Can I specify a variable after step or must it be explicit?
Yep, you can use variables on the step argument

This topic is closed to new replies.

Advertisement