我想跳到下面的陈述中的下一行
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
如何跳过下一行没有经过整个循环?
答案 0 :(得分:1)
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
答案 1 :(得分: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