deleting lines in a text file

how to delete for example the first 5 lines in a text file?
Who is Participating?
robertleesConnect With a Mentor Commented:
You are going to have to copy the lines you want to a new file, kill the original file, then rename the new file.

For example, to delete the first 5 lines from c:\MyFile.txt

Call DeleteLines("c:\MyFile.txt", 5)

Sub DeleteLines(ByVal strFile As String, ByVal intLines As Integer)
    Dim strRecord As String
    Open strFile For Input As #1
    Open strFile & ".new" For Output As #1
    Do Until EOF(1)
        Line Input #1, strRecord
        intLines = intLines - 1
        If intLines <= 0 Then
            Print #2, strRecord
        End If
    Close #1
    Close #2
    Kill strFile
    Name strFile & ".new" As strFile
End Sub
All Courses

From novice to tech pro — start learning today.