Changing end integer of a loop within said loop

Viewed 50

I am working on some code and I am trying to modify the end integer of a loop within said loop (as said in the title)

So it would look like this

dim x as integer

For i=0 to x
    if (some conditions) then
        x=x+1
    End if
Next 

However it doesn't seem to work, it looks like the loop is working with a static value of x and not a dynamic value.

Is there a way to update the end integer of the loop without using an exit for and starting the loop all over?

Thanks

1 Answers

You can use a While loop.

dim x as integer
Dim i as Integer = 0

While i <= x
    if (some conditions) then
        x=x+1
    End if
End While 
Related