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

delete first line in txt and rewrite

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
411
0
16
IT
I need to delete the first line in txt, from c:\mydir\test.txt and rewrite it in c:\mydir\test_ok.txt.
Tks
 
A tiny modificatiopn of the Rewrite function previously provided in thread222-1826297

Code:
[COLOR=blue]Public Sub Rewrite2(strIn As String, strOut As String)
    Dim Instream As Object
    With New FileSystemObject
        Set Instream = .OpenTextFile(strIn, ForReading)
        Instream.SkipLine
        .OpenTextFile(strOut, ForWriting, True).Write Instream.ReadAll
    End With
End Sub[/color]

Or if, as I somewhat suspect, both these questions are related, here is removing the first line and replacing the characters

Code:
[COLOR=blue]Public Sub Rewrite2(strIn As String, strOut As String)
    Dim Instream As Object
    With New FileSystemObject
        Set Instream = .OpenTextFile(strIn, ForReading)
        Instream.SkipLine
        .OpenTextFile(strOut, ForWriting, True).Write Replace(Instream.ReadAll, ";", ",")
    End With
End Sub[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top