View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Taking two passes at at Text File using Do Until Loops

Perhaps if you explain what you are actually doing with the file, then maybe
we can give you a different approach then the one you have locked onto. For
example, what is the "some condition" that ends your first loop... what is
the "do something" in your second loop? Also, what kind of data structure is
used in your text file?

--
Rick (MVP - Excel)


"ExcelMonkey" wrote in message
...
I Am loping through a text file. I need to take two passes at the file.
When
I exit the first loop I then proceed to the next loop where I want to
start
searching the file again from the first line. However the sData variable
is
still set to the line where the first loop exited the Do. How do I
restart
this? I tried using the "Open x For Input As #1" again in the second loop
but I recieved an error message saying the file was already open.

'First Pass
Open x For Input As #1
Do While EOF(1)
Line Input #1, sData
LineCount = LineCount + 1
If some condition = True Then
Exit Do
End if
Loop

LineCount = 0

'Second Pass
Do While EOF(1)
Line Input #1, sData
LineCount = LineCount + 1
'Do something
Loop

Thanks

EM