VBA Exit For语句
2024-08-26 21:42:42
当想要根据特定标准退出For
循环时,就可以使用Exit For
语句。当执行Exit For
时,控件会立即跳转到For
循环之后的下一个语句。
语法
以下是在VBA中Exit For
语句的语法。
Exit For
流程图
示例
以下使用Exit For
语句的示例。 如果计数器(i
)的值达到4
,则退出For
循环,并在For
循环之后立即跳转到下一个语句。
Private Sub Constant_demo_Click()
Dim a As Integer
a = For i = To a Step 'i is the counter variable and it is incremented by 2
MsgBox ("The value is i is : " & i)
If i = Then
i = i * 'This is executed only if i=4
MsgBox ("The value is i is : " & i)
Exit For 'Exited when i=4
End If
Next
End Sub
当执行上面的代码时,它将在消息框中输出以下输出。
The value is i is : The value is i is : The value is i is : The value is i is :
最新文章
- .Net使用RabbitMQ详解
- Android之ListView性能优化——使用ConvertView和ViewHolder
- iOS开发零基础--Swift教程 可选类型
- Android 调用系统照相机拍照和录像
- java 对象传递 是 值传递 还是 引用传递?
- ChainOfResponsibility
- hdu 1718 Rank
- linux两台server远程copy文件
- 3.21	采购订单导入MDS
- Android中SharedPreferences介绍和使用方法
- spring MVC(十)---spring MVC整合mybatis
- SpringBoot系列——Redis
- EffectiveC++ 第5章 实现
- RedHat Enterprise Linux 6.4使用网易Centos 6 的yum源
- Oracle SQL Developer 调试存储过程步骤(Oracle)
- Java 一致性Hash算法的学习
- 使用jquery提交FormData数据
- python网络编程知识体系
- Mac下使用Eclipse的Show in Terminal提示command not found: mvn
- locatin