Exit a while loop in VBS/VBA

前端 未结 6 1782
天涯浪人
天涯浪人 2020-12-11 14:25

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 (s         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 15:15

    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
    

提交回复
热议问题