Exit a while loop in VBS/VBA
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}