Next row in a datatable loop?
Hi all,
Just curious is there a "next row" method when looping through a datatable?
Basically, I want to be able to go to the next row without having to go to the end of the loop. See my coded example:
Code:
For Each row As DataRow In dt.Rows
Dim MyCondition as Boolean = ClassConditions.ConditionA
Try
If MyCondition = True then
'I'd like something here that would go to next row
end if
Catch ex As Exception
'error trapping code
End Try
Next row
If I can't do it this way is there some alternative way of accomplishing? I'm using VB 2005
Thanks,
Strick
Re: Next row in a datatable loop?
It's not specific to DataTables at all but you can use the Continue For statement in a For or For Each loop to jump to the next iteration. That said, it's often very simple to do the same thing without a Continue statement, usually by simply inverting an If condition. Can we see the whole code block?
Re: Next row in a datatable loop?