打破了一阵子… Wend循环

我正在使用VBA的Wend循环。

Dim count as Integer While True count=count+1 If count = 10 Then ''What should be the statement to break the While...Wend loop? ''Break or Exit While not working EndIf Wend 

我不想使用条件,如“虽然计数<= 10 … Wend

一个While/Wend只能通过一个GOTO或者从一个外部块Exit subExit sub / function / another exitable loop

更改为Do循环intead;

 Do While True count = count + 1 If count = 10 Then Exit Do End If Loop 

(或者用一个增量控制variables循环)

 for count = 1 to 10 msgbox count next