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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove line breaks every two lines 1

Status
Not open for further replies.

M626

Programmer
Mar 13, 2002
299
I have a file that look something like:

1
2
3
4
5
6

I would like to open the file and resort it so it ever two line are on the same line like

1 2
3 4
5 6
 
Is this a text file?

If so
Code:
Dim n       As Integer
Dim cBufIn  As String
Dim cBufOut As String
Dim nHI     As Integer
Dim nHO     As Integer

nHI = FreeFile
Open "SomeFile.Txt" For Input As #nHI
nHO = FreeFile
Open "SomeOtherFile.Txt" For Output As #nHO

Do Until EOF(nH)
   n = n + 1
   Line Input #nH, cBufIn
   cBufOut = cBufOut & " " & cBufIn
   If n Mod 2 = 0 Then
      Print #nHO, Trim(cBufOut)
      cBufOut = ""
   End If
Loop
If Len(cBufOut) > 0 Then Print #nHO, Trim(cBufOut)

Close nHI
Close nHO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top