Q: For Each loops by:Geoff Jones
|
Hi
Suppose I have a For Each loop, for example,
For Each x As DataRow In drMyData
' Do stuff - calculation 1
' Do more stuff - calculation 2
' and even more stuff - calculation 3
Next
If after completing calculation 1, I discover that there is no point doing
calculations 2 and 3, how do I jump back to the start to starting processing
the next DataRow?
I've tried adding a conditional statement something like:
If (no point carrying on) Then
Next
End if
but I can't get it to compile.
Can anybody please help?
Thanks in advance
Geoff
|
| | Reply: by:One Handed Man \( OHM - Terry Burns \)
|
| | Simply structure your code differently with conditional branching such as
select case and if's, if you cant cope with that then you could put a goto
statement in, but I try to avoid this if possible
if then goto continue
continue:
Next
--
Terry Burns
|
| | Reply: by:Anonymous
|
| | why not just do this?
For Each x As DataRow In drMyData
' Do stuff - calculation 1
' Do more stuff - calculation 2
' and even more stuff - calculation 3
|
| | Reply: by:Anonymous
|
| | not just do this?
For Each x As DataRow In drMyData
' Do stuff - calculation 1
if calculation1ok then
' Do more stuff - calculation 2
if calculation2ok then
' and even more stuff - calculation 3
end if
end if
Next
hth
guy
|
| | Reply: by:PAul Maskens
|
| | Well, it is a FOR loop, how about using LOOP ?
If you want to exit and stop processing any more rows, use EXIT
|
0 Comments:
Post a Comment
<< Home