Link to home
Start Free TrialLog in
Avatar of Stephen Manderson
Stephen MandersonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Help with stop - start of a loop

Hi All

I have the following attached loop that runs through 300+ mil loops generated from 3 Lists of string.

District, inner & ending

Is there any way to save the current position from the "For each .. as string in .." and then load the position back in ? Just that I have an estimated run time of 500+ hours and would like to be able to resume from a stored position should I have to.

I am also opened to other ideas aswell :-)

Many Thanks
Steve

Dim District, Inner, Ending As New List(Of String)
 
        District = DistrictList()
        Inner = InnerList()
        Ending = EndingList()
 
        For Each d1 As String In District
            s1 = d1
            For Each i1 As String In Inner
                s2 = s1 & i1
                For Each e1 As String In Ending
                    s3 = s2 & " " & e1
 
                    While pauseLoop
                        System.Threading.Thread.Sleep(100)
                        Application.DoEvents()
                    End While
 
                    Application.DoEvents()
 
                Next
            Next
        Next

Open in new window

SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>Sancler
your code has the flaw that when you start with 0,5,0, it will skip the values for the second loop from 0..4 for ALL the value of the first loop... which is no good :)
Avatar of Sancler
Sancler

angelIII

What about the third line from the end

     iStart = 0

Before dIndex goes from 0 to 1, iStart is reset to 0.

I must admit I haven't tested it, though.  Do you still reckon there's a flaw?

Roger
oooops, I overlooked that! I stand corrected!
Avatar of Stephen Manderson

ASKER

Thanks