本文介绍了VBS 错误:“预期的语句结束"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一定是忽略了一些非常明显的东西.以下代码在下一行失败并显示错误消息预期语句结束":
I must be overlooking something painfully obvious. The following code fails on the Next line with the error message "Expected end of statement":
Option Explicit
GetB
Sub GetB()
Dim i
For i = 1 to 2
Msgbox i
Next i
End Sub
推荐答案
找到了.Next 语句中循环变量 ("i") 的重复,在所有其他类似 BASIC (B*SIC?) 的语言中都是合法和可选的,但在 VBS 中是非法的.
Found it. The repetition of the loop variable ("i") in the Next statement, which is legal and optional in every other BASIC-like (B*SIC?) language, is illegal in VBS.
代码应该是:
Option Explicit
GetB
Sub GetB()
Dim i
For i = 1 to 2
Msgbox i
Next
End Sub
这篇关于VBS 错误:“预期的语句结束"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!