I have been experimenting with DoEvents to allow the user to cancel processing of the following code.
Without using DoEvents the process takes 1 min 27 sec.
With DoEvents in the outer loop as shown, it takes 3 min 1 sec.
But if I Rem out the first DoEvents and un-rem the second the process takes a whopping 8 min 45 secs.
For a = 0 To cmbSites.ListCount - 1
DoEvents
If CancelErr Then Exit For
Open App.Path & "\" & IP(a) & ".txt" For Output As #2
For i = 0 To lstCsvfiles.ListCount - 1
StatusBar1.Panels(1).Text = "Scanning " & lstCsvfiles.List(i) & " for " & IP(a)
Open lstCsvfiles.List(i) For Input As #1
Do While Not EOF(1)
'DoEvents
'If CancelErr Then Exit For
Line Input #1, FileString
If InStr(FileString, IP(a)) Then
Print #2, FileString
End If
Loop
Close #1
Next i
Close #2
Next a
Is there a more efficient way of allowing the user to cancel a process?
Alan
[gray]Experience is something you don't get until just after you need it.[/gray]
Without using DoEvents the process takes 1 min 27 sec.
With DoEvents in the outer loop as shown, it takes 3 min 1 sec.
But if I Rem out the first DoEvents and un-rem the second the process takes a whopping 8 min 45 secs.
For a = 0 To cmbSites.ListCount - 1
DoEvents
If CancelErr Then Exit For
Open App.Path & "\" & IP(a) & ".txt" For Output As #2
For i = 0 To lstCsvfiles.ListCount - 1
StatusBar1.Panels(1).Text = "Scanning " & lstCsvfiles.List(i) & " for " & IP(a)
Open lstCsvfiles.List(i) For Input As #1
Do While Not EOF(1)
'DoEvents
'If CancelErr Then Exit For
Line Input #1, FileString
If InStr(FileString, IP(a)) Then
Print #2, FileString
End If
Loop
Close #1
Next i
Close #2
Next a
Is there a more efficient way of allowing the user to cancel a process?
Alan
[gray]Experience is something you don't get until just after you need it.[/gray]