首页 > 学院 > 开发设计 > 正文

ASP如何跳出本次进入下一次循环

2019-11-18 16:37:40
字体:
来源:转载
供稿:网友

看下面的java代码,目的是为了当i是3的时候,就不做输出,直接跳到下一个循环。

        int i = 0;
        while (i < 5) ...{
            i++;
            if (i == 3) ...{
                continue;
            }
            System.out.PRintln("I'm not 3, I'm " + i);
            // Do something else...
        }
 然而在asp (VB) 应该怎么写呢?不少人就犯难了。在此,我给出些答案供参考,还往多多指教!

    i = 0
    Do While (i < 5)
        If (i <> 3) Then
            'MsgBox "I'm not 3, I'm " & i
            'Do something else...

        End If
        i = i + 1
    Loop
 显然,上面的例子会贻笑大方。

    i = 0
    Do While (i < 5)
        For j = 1 To 1
            If (i = 3) Then
                Exit For
            End If
            'MsgBox "I'm not 3, I'm " & i
            'Do something else...
           
        Next j
        i = i + 1
    Loop

http://blog.csdn.net/chyzan/archive/2007/03/15/1530645.aspx


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表