Link to home
Start Free TrialLog in
Avatar of underground712
underground712

asked on

3 lines in one

i have a text file
c:\Bob\log.txt
it has info on 3 lines that i need in a new text file,with the 3 lines combined, then loop thru the whole text file and combine
 
bob
fred
stan
mel
ralph
pete

bob fred stan
mel ralph pete
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Open "MyFile1" For Input As #1
Open "MyFile2" For Output As #2
Do
  Input Line #1,strLine1
  Input Line #1,strLine2
  Input Line #1,strLine3
  Print #2,strLine1 & " " & strLine2 & " " & strLine3
Loop Until Eof(1)
Close #1
Close #2
Sorry that should be:

Open "MyFile1" For Input As #1
Open "MyFile2" For Output As #2
Do
 Line Input #1,strLine1
 Line Input #1,strLine2
 Line Input #1,strLine3
 Print #2,strLine1 & " " & strLine2 & " " & strLine3
Loop Until Eof(1)
Close #1
Close #2
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland 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
Open "MyFile1" For Input As #1
Open "MyFile2" For Output As #2
Do Until Eof(1)
Line Input #1,strLine1
Line Input #1,strLine2
Line Input #1,strLine3
Print #2,strLine1 & " " & strLine2 & " " & strLine3
Loop
Close #1
Close #2
Avatar of eosu
eosu

Sorry - not clear on the question - you want every 3 lines merged into 1? or just the first 3, in which case what do you want done with the remaining lines?