Learn how to a build a cloud-first strategyRegister Now


Restart at the begining of the for each

Posted on 2009-02-11
Medium Priority
Last Modified: 2012-05-06
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.
Question by:mathieu_cupryk
  • 2
LVL 70

Expert Comment

by:Éric Moreau
ID: 23613421
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?
LVL 70

Expert Comment

by:Éric Moreau
ID: 23613438
also, we normally see the break statement in a switch structure (Case in VB).
LVL 27

Accepted Solution

VBRocks earned 2000 total points
ID: 23613461
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



Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question