Exit a while loop in VBS/VBA

前端 未结 6 1783
天涯浪人
天涯浪人 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 14:59

    Use Do...Loop with Until keyword

    num=0
    Do Until //certain_condition_to_break_loop
     num=num+1
    Loop
    

    This loop will continue to execute, Until the condition becomes true

    While...Wend is the old syntax and does not provide feature to break loop! Prefer do while loops

提交回复
热议问题