Possibly another way
VB Code:
Dim Prts() As String Dim txtFile As String 'Read the file Open "D:\test.txt" For Input As #1 txtFile = Input(FileLen("D:\test.txt"), 1) Close #1 'Split the text Prts() = Split(txtFile, vbCrLf) 'If the last three lines are empty then remove them If Prts(UBound(Prts)) = "" And Prts(UBound(Prts) - 1) = "" And Prts(UBound(Prts) - 2) = "" Then ReDim Preserve Prts(UBound(Prts) - 3) End If 'Re put the parts back together txtFile = Join(Prts(), vbCrLf) 'Write it back Open "D:\test.txt" For Output As #1 Print #1, txtFile Close #1




Reply With Quote