• 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
                    break;?
I am not sure if it is break to restart at the beginning of the for each.
0
mathieu_cupryk
Asked:
mathieu_cupryk
  • 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?
0
 
Éric MoreauSenior .Net ConsultantCommented:
also, we normally see the break statement in a switch structure (Case in VB).
0
 
VBRocksCommented:
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

     Else
              ' Do something...
     End If

Next

0
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