Do… Loop Until with multiple conditions

前端 未结 3 376
醉酒成梦
醉酒成梦 2021-01-20 16:30

I have a quick question about which I did not find specific information on the web. I want to perform a Do...Loop Until loop, but I would like to insert more th

3条回答
  •  时光取名叫无心
    2021-01-20 17:18

    The below example shows lazy evaluation implementation:

    Do
        ' some operations
        Select Case False
            Case Condition1
            Case Condition2
            Case Condition3
            Case ConditionN
            Case Else Exit Do
        End Select
    Loop
    

    Such code allows to improve performance and speed up code execution. It evaluates conditions one by one until first false result only, if all conditions are true then it exits the loop, while conventional And operators evaluate all conditions regardless of the results.

提交回复
热议问题