Results 1 to 4 of 4

Thread: [RESOLVED] Adding Chars At the End Of Each Line Of A Text File

  1. #1

    Thread Starter
    Lively Member GhostRider888's Avatar
    Join Date
    Apr 2007
    Posts
    113

    Resolved [RESOLVED] Adding Chars At the End Of Each Line Of A Text File

    HI, i want to add two characters and the end of each line of a text file

    For example ";;" :

    before.txt

    abcdefghijklmnopqrstuvwxyz
    abcdefghijklmnopqrstuvwxyz
    abcdefghijklmnopqrstuvwxyz

    after.txt

    abcdefghijklmnopqrstuvwxyz;;
    abcdefghijklmnopqrstuvwxyz;;
    abcdefghijklmnopqrstuvwxyz;;

    I know its something with "nextline" (maybe) but
    i didnt figure it out when i tried
    Last edited by GhostRider888; Jul 23rd, 2007 at 02:15 AM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Adding Chars At the End Of Each Line Of A Text File

    You would basically have to re-write the file so the following:
    Code:
    Private Sub Command2_Click()
    Dim sFile As String
    Dim sText As String
    Dim arLines() As String
    Dim i As Long
    Dim newChar As String
    
        newChar = ";" 'or whatever you need to add at the end of each line
        
        Open sFile For Input As #1
            sText = Input(LOF(1), #1)
        Close #1
        arLines = Split(sText, vbNewLine)
        sText = ""
        
        Open sFile For Output As 31
            For i = 0 To UBound(arLines)
                Print #1, arLines(i) & newChar
            Next i
        Close #1
        
        Erase arLines
    
    End Sub

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Adding Chars At the End Of Each Line Of A Text File

    Or update the delimiter

    arLines = Split(sText, vbNewLine)
    sText = Join(arLInes, ";;" & vbNewLine)
    Print #1, sText

  4. #4

    Thread Starter
    Lively Member GhostRider888's Avatar
    Join Date
    Apr 2007
    Posts
    113

    Re: Adding Chars At the End Of Each Line Of A Text File

    Thank u very much!!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width