Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 在所述循环内改变循环的结束整数_Vb.net_Loops_For Loop - Fatal编程技术网

Vb.net 在所述循环内改变循环的结束整数

Vb.net 在所述循环内改变循环的结束整数,vb.net,loops,for-loop,Vb.net,Loops,For Loop,我正在编写一些代码,并试图修改所述循环中循环的结束整数(如标题中所述) 看起来是这样的 dim x as integer For i=0 to x if (some conditions) then x=x+1 End if Next 然而,它似乎不起作用,它看起来像是在使用静态值x而不是动态值 是否有一种方法可以更新循环的结束整数,而不必使用的退出并重新启动循环 谢谢您可以使用While循环 dim x as integer Dim i as Intege

我正在编写一些代码,并试图修改所述循环中循环的结束整数(如标题中所述)

看起来是这样的

dim x as integer

For i=0 to x
    if (some conditions) then
        x=x+1
    End if
Next 
然而,它似乎不起作用,它看起来像是在使用静态值x而不是动态值

是否有一种方法可以更新循环的结束整数,而不必使用的退出并重新启动循环


谢谢

您可以使用While循环

dim x as integer
Dim i as Integer = 0

While i <= x
    if (some conditions) then
        x=x+1
    End if
End While 
dim x作为整数
尺寸i为整数=0

虽然我非常感谢,但我已经习惯于只使用for循环,以至于我甚至没有想过使用另一种循环……在的文档中,在“技术实现”部分中说,循环限制在开始时只评估一次。也: