【发布时间】:2014-05-31 02:19:38
【问题描述】:
下面的代码是 VBA for Excel。我正在使用 Excel 2007 附带的 Visual Basic 编辑器。
Dim counter As Integer
counter = 1
While counter < 20
counter = counter + 1
end while '<- the compiler is complaining about this statement
代码无法编译。在代码上方我只有声明。根据MSDN,这应该可以工作,但不能。发生了什么事?
【问题讨论】:
-
到目前为止的两个答案中(
Do While / Loop和While / Wend)我推荐Do While选项,原因很简单,如果需要,您可以使用Exit Do打破这个循环功能。