Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text File re-format - skips last line 1

Status
Not open for further replies.

jcw5107

Technical User
Jan 31, 2007
66
0
0
US
I am working with some code that - for some reason - it skips that last line in the text file...?? I just can't figure it out....

Below is what I am working with...
Can anybody help me out with some suggestions or examples..??
Thanks in advance..!!
jcw5107

Dim intFileIn As Integer, intFileOut As Integer
Dim strReadBuffer As String, strWriteBuffer


intFileIn = FreeFile
Open "D:\UPSDATA\SchedWorkWAN1.txt" For Input As #intFileIn
intFileOut = FreeFile
Open "D:\UPSDATA\SchedWorkWAN2.txt" For Output As #intFileOut

Line Input #intFileIn, strReadBuffer
Do While Not EOF(intFileIn)
strWriteBuffer = strWriteBuffer & " " & strReadBuffer
Line Input #intFileIn, strReadBuffer
If Left(strReadBuffer, 2) = "E " _
Or Left(strReadBuffer, 2) = "S " _
Or Left(strReadBuffer, 2) = "P " Then
Print #intFileOut, strWriteBuffer
strWriteBuffer = ""
End If
Loop
Close #intFileIn
Close #intFileOut
 
Code:
Do While Not EOF(intFileIn)
strWriteBuffer = strWriteBuffer & " " & strReadBuffer
Line Input #intFileIn, strReadBuffe

The second line of this code will still execute after the last Line Input (it's not EOF until the code hits the third line above).



Did you hear about the Buddhist who refused Novocain during a root
canal? He wanted to transcend dental medication.
 
genomon,

I am tryin' to grasp what your tellin' me but I'm hung up..!!!

The text file looks like this:
E
Test ECAM message
S
Remove and replace the computer
P
Install EADI

I want it to look like:
E Test ECAM message
S Remove and replace the computer
P Install EADI

Every single line that starts with E,S or P will have a "description" right underneath the respective line. I'm tryin' to get the description on the same line as the E,S or P above it...

Thanks for help..!! Any other suggestions or more direction..??
Thanks..!!
jcw5107
 
Code:
Dim intFileIn As Integer, intFileOut As Integer
Dim strReadBuffer As String, strWriteBuffer


intFileIn = FreeFile
Open "D:\UPSDATA\SchedWorkWAN1.txt" For Input As #intFileIn
intFileOut = FreeFile
Open "D:\UPSDATA\SchedWorkWAN2.txt" For Output As #intFileOut

Do While Not EOF(intFileIn)
   Line Input #intFileIn, strReadBuffer
   strWriteBuffer = strReadBuffer
   If Left(strReadBuffer, 2) = "E " Or _
      Left(strReadBuffer, 2) = "S " Or _
      Left(strReadBuffer, 2) = "P " Then
         Line Input #intFileIn, strReadBuffer
         strWriteBuffer = strWriteBuffer & " " & strReadBuffer
   End If
   Print #intFileOut, strWriteBuffer
Loop
Close #intFileIn
Close #intFileOut

If you are 100% sure that "Every single line that starts with E,S or P will have a "description" right underneath the respective line.
 
JerryKlmns,

Thank you so much...!!
That was what I was lookin' for..!!
Star for you..!!

jcw5107
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top