Results 1 to 15 of 15

Thread: [RESOLVED] [2005] Skip to Next in 'For Each' loop?

Threaded View

  1. #1

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Resolved [RESOLVED] [2005] Skip to Next in 'For Each' loop?

    Hello everyone:

    I have a 'For Each' loop that contains some items I don't want to analyse. Now I use a GoTo command to 'skip' an item. But this is not very elegant and (knowing .NET) there is probably a way to skip to the next item without using GoTo.

    I'll show you a simplified version of my loop, designed to add all animals to a list, except the Leopard :
    (Indeed, simplified, because there's like two pages of code in the real loop. )
    VB Code:
    1. For Each Animal As String In Animals
    2.         If Animal = "Leopard" Then GoTo OhNoALeopard
    3.  
    4.         ListBox.Items.Add(Animal)
    5.  
    6. OhNoALeopard:
    7.     Next

    Thanks for any help.
    Last edited by arsmakman; Jul 16th, 2006 at 08:14 AM.
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width