[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 :sick:
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
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
Re: Adding Chars At the End Of Each Line Of A Text File