Exit a while loop in VBS/VBA

前端 未结 6 1795
天涯浪人
天涯浪人 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:23

    While Loop is an obsolete structure, I would recommend you to replace "While loop" to "Do While..loop", and you will able to use Exit clause.

    check = 0 
    
    Do while not rs.EOF 
       if rs("reg_code") = rcode then 
          check = 1 
          Response.Write ("Found") 
          Exit do
       else 
          rs.MoveNext 
        end if 
    Loop 
    
    if check = 0 then 
       Response.Write "Not Found" 
    end if}
    

提交回复
热议问题