J
Jac Tremblay
Hi, all of you
I have over 20 text files, some of which may include over 40000 lines of text. I only need to remove the return of the last line. Here is some code that works, thanks to kkknie
' *********************************************************************
Sub TestWithOpen(
' Jac Tremblay 2004-04-1
Dim strPathDat As Strin
Dim strNameDat As Strin
Dim strNameDat2 As Strin
Dim strLineText As Strin
Dim intI As Intege
Dim intJ As Intege
Dim strLine() As Strin
strPathDat = "C:\DaDest\
strNameDat = "SCAT0107.DAT
strNameDat2 = "SCAT0199.DAT
Open strPathDat & strNameDat For Input As #
Open strPathDat & strNameDat2 For Output As #
intI =
Do While Not EOF(1
Line Input #1, strLineTex
intI = intI +
ReDim Preserve strLine(intI
strLine(intI) = strLineTex
Loo
For intJ = 1 To int
strLineText = strLine(intJ
If intJ = intI The
Print #2, strLineText
Els
Print #2, strLineTex
End I
Next int
Close #
Close #
End Su
' *********************************************************************
Now, I think that this code could be simpler but cannot figure out how. For one thing, I know that I will have to to use Long instead of Integer for the big files. But the main problem is that I need to store all the lines in a temporary array an then rewrite the whole file in a second file. I will later have to delete the fisrt one. What a waste of energy and precious time!..
Anyone can help
Thank you.
I have over 20 text files, some of which may include over 40000 lines of text. I only need to remove the return of the last line. Here is some code that works, thanks to kkknie
' *********************************************************************
Sub TestWithOpen(
' Jac Tremblay 2004-04-1
Dim strPathDat As Strin
Dim strNameDat As Strin
Dim strNameDat2 As Strin
Dim strLineText As Strin
Dim intI As Intege
Dim intJ As Intege
Dim strLine() As Strin
strPathDat = "C:\DaDest\
strNameDat = "SCAT0107.DAT
strNameDat2 = "SCAT0199.DAT
Open strPathDat & strNameDat For Input As #
Open strPathDat & strNameDat2 For Output As #
intI =
Do While Not EOF(1
Line Input #1, strLineTex
intI = intI +
ReDim Preserve strLine(intI
strLine(intI) = strLineTex
Loo
For intJ = 1 To int
strLineText = strLine(intJ
If intJ = intI The
Print #2, strLineText
Els
Print #2, strLineTex
End I
Next int
Close #
Close #
End Su
' *********************************************************************
Now, I think that this code could be simpler but cannot figure out how. For one thing, I know that I will have to to use Long instead of Integer for the big files. But the main problem is that I need to store all the lines in a temporary array an then rewrite the whole file in a second file. I will later have to delete the fisrt one. What a waste of energy and precious time!..
Anyone can help
Thank you.