1

我想跳到下面语句的下一行

For iRow = 0 To dsDiscnt.Tables(0).Rows.Count - 1
     rowDiscnt = dsDiscnt.Tables(0).Rows(iRow)

     If rowdiscnt.Item("x") = "S" Then
         'skip to next row
     Else
         'continue loop
     End If

'do something...
Next

如何在不遍历整个循环的情况下跳到下一行?

4

2 回答 2

3

Continue For是您需要的语句,如下所示:

For iRow = 0 To dsDiscnt.Tables(0).Rows.Count - 1
    rowDiscnt = dsDiscnt.Tables(0).Rows(iRow)

    If rowdiscnt.Item("x") = "S" Then
        ' Skip to next iteration of For loop
        Continue For
    Else
        ' Keep doing work in this iteration of the For loop
    End If

    'do something...
Next
于 2013-09-18T03:53:27.737 回答
0
For iRow = 0 To dsDiscnt.Tables(0).Rows.Count - 1
     rowDiscnt = dsDiscnt.Tables(0).Rows(iRow)

     If rowdiscnt.Item("x") = "S" Then
         break;//'skip to next row
     Else
         'continue loop
     End If

'do something...
Next

编辑

For iRow = 0 To dsDiscnt.Tables(0).Rows.Count - 1
     rowDiscnt = dsDiscnt.Tables(0).Rows(iRow)

     If rowdiscnt.Item("x") = "S" Then
         Continue For;//'skip to next row
     Else
         'continue loop
     End If

'do something...
Next
于 2013-09-18T03:53:25.057 回答