简体   繁体   中英

VB.net 1.1 - Is there a Continue For?

必须使用记事本维护一个使用VB.net 1.1的旧网站:(我有一些代码,我为一些我们的.Net 4网站写的老板男人想要移植到旧网站。找到VB.net 1.1代码的例子在For / Next块中显示使用“Continue For”跳转到下一个迭代。然而,当我在代码中尝试它时,我得到一个例外,“名称'继续'尚未声明。”这应该是否可用,或者示例不正确,它是.Net 2.0的东西?

Continue statement was added in VS 2005.

If you really need you could use a GoTo statement to jump to the end. I've never needed a GoTo myself in 7 years of development in VB.NET with VS 2003.

Seems to remember that Continue For was added to the language in 2005.

Yes a little research leads to this confirmation

Continue For
Continue Do
Continue While

were added in VB.2005, previously you have only the nasty GOTO

This is one of the very few situations when GoTo is all right. Look:

For count = 1 To 100
   If itsMillerTime Then Goto ContinueFor

   ' More stuff here

  ContinueFor:
Next

Semantically identical to Continue For.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM