本文介绍了在 VBS/VBA 中退出 while 循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 VBS/VBA 中是否有退出/破坏 while
的方法?
Is there a method of exiting/breaking a while
in VBS/VBA?
以下代码无法按预期工作:
Following code won't work as intended:
num = 0
while (num < 10)
if (status = "Fail") then
exit while
end if
num = num+1
wend
推荐答案
VBScript 的 While
循环不支持提前退出.使用 Do
循环:
VBScript's While
loops don't support early exit. Use the Do
loop for that:
num = 0
do while (num < 10)
if (status = "Fail") then exit do
num = num + 1
loop
这篇关于在 VBS/VBA 中退出 while 循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!