VBA 编程:循环、代码文档、错误调试与处理
1. 创建 For…Next 循环
1.1 操作步骤
- 将以下
TestLoop过程的代码放置在modBusinessLogic标准模块中:
Sub TestLoop()
'declare variable to store Counter
Dim intCounter As Integer
'increment intCounter from 1 to 5 and
'display output in debug window
For intCounter = 1 To 5
Debug.Print intCounter
Next intCounter
End Sub
- 从立即窗口运行
TestLoop过程。
1.2 工作原理
TestLoop 过程首先声明一个 intCounter 变量来存储循环迭代的次数。 For...Next 语句指定循环从 intCounter 为 1 开始,重复执行直到 intCounter 达到 5。 Next 语句将 intCounter </
VBA编程:循环、文档化与错误处理
超级会员免费看
订阅专栏 解锁全文
1093

被折叠的 条评论
为什么被折叠?



