Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo

  Q: For Each loops (Monday, January 30, 2006)




Found the following interesting discussion in the Newsgroups:

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







 
Previous Posts
    - How to find a list of SQL Servers?
    - How to find whether an Image is Color or b/w?
    - Find Missing Data
    - Design Tutorials
    - Dateformat on databound textboxes?
    - Moveable Toolbars
    - Help with hiding LinkButton in DataList
    - Project converted from VB6 to VB.Net gets subclass...
    - .Net says I'm not Online, but I am!
    - Freeware/shareware Windows controls

Archives
    - 2006-01-01
    - 2006-01-08
    - 2006-01-15
    - 2006-01-22
    - 2006-01-29


Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland