• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

Restart at the begining of the for each

I have the following
For Each filename As String In ListofFiles

                If (Path.GetExtension(filename).Equals(".TXT") Or Path.GetExtension(filename).Equals(".txt")) Then
I am not sure if it is break to restart at the beginning of the for each.
  • 2
1 Solution
Éric MoreauSenior .Net ConsultantCommented:
are you converting C# to VB.Net? Usually break is to get out of a structure (outside the For in your case). Can we see the original C# code?
Éric MoreauSenior .Net ConsultantCommented:
also, we normally see the break statement in a switch structure (Case in VB).
Well, you can use "Continue For" if you want to skip the item and keep iterating through the loop.

If you want to actually start over, then you will have to do it this way:

Dim ext As String = String.Empty

For i As Integer = 0 to ListOfFiles.Length - 1

     ext = Path.GetExtension(ListOfFiles(i)).ToLower()

     If ext.Equals(".txt")) Then

               i = 0  'reset

              ' Do something...
     End If


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now