zoukankan      html  css  js  c++  java
  • 关于VBA的Exit For到底是怎样跳出for循环的小例子

    关于VBA的Exit For到底是怎样跳出for循环的小例子
    原创darer49 发布于2018-04-25 09:35:18 阅读数 10562  收藏
    展开

    跳出for循环大概三种层次

    (1)跳出本次for循环,进行本层的下一次循环

    (2)跳出本层for循环,执行for语句之外的其他语句

    (3)跳出整个嵌套循环,执行嵌套循环以外的语句

    本菜写的小例子如下:

    Sub try()
    Dim i As Integer
    Dim j As Integer
     
    For i = 1 To 10
        For j = 1 To 10
            If j < 2 Then
                Exit For
            End If
            Debug.Print "--"; j
        Next j
        
        Debug.Print i
    Next i
    Debug.Print "`````````````````"
    End Sub
    可能结果:

    ①“--j”,j从2到10的所有数字

    ②“i”从1到10的所有数字

    ③一行“````````”

    可以看出:

    (1)如果跳出本次for循环的话,得到①②③

    (2)如果跳出本层for循环的话,得到②③

    (3)如果跳出所有for循环的话,得到③

    最后结果如下:

     1 
     2 
     3 
     4 
     5 
     6 
     7 
     8 
     9 
     10 
    `````````````````
    得到②③,符合条件(2)

    结论:Exit For是跳出本层循环,执行本层for语句之外的其他语句
    ————————————————
    版权声明:本文为CSDN博主「darer49」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/darer49/article/details/80074309

  • 相关阅读:
    python语法_1基础语法概述
    Pytest用例编写1
    Pytest介绍
    9、Selenium grid2
    虫师Selenium2+Python_8、自动化测试高级应用
    虫师Selenium2+Python_7、unittest单元测试框架
    虫师Selenium2+Python_6、Selenium IDE
    虫师Selenium2+Python_5、自动化测试模型
    虫师Selenium2+Python_4、webdriver API
    虫师Selenium2+Python_3、Python基础
  • 原文地址:https://www.cnblogs.com/grj001/p/12223134.html
Copyright © 2011-2022 走看看