B4J Question WriteLine function

PatrikCavina

Active Member
Licensed User
Longtime User
I tried to write more lines in .txt file with function WriteLine, but the result is a txt file with only one line.
This is an example of what i want to do:
Code:
    Dim f As TextWriter
    f.Initialize(File.OpenOutput("C:\Users\user01\Desktop","a.txt",True))
    f.WriteLine("1")
    f.WriteLine("2")
    f.WriteLine("3")
    f.Close

I tried also:
Code:
Sub AppStart (Form1 As Form, Args() As String)

    Dim st() As String = Array As String("1","2","3")
    For i = 0 To st.Length-1
   
        Write(st(i))
   
    Next
   
End Sub

Sub Write(tx As String)

    Dim f As TextWriter
    f.Initialize(File.OpenOutput("C:\Users\user01\Desktop","a.txt",True))
    f.WriteLine(tx)
    f.Close

End Sub

But the result is the same, all strings are written in only one line
 
Add newline code.

Code:
Dim f As TextWriter
    f.Initialize(File.OpenOutput("C:\Users\user01\Desktop","a.txt",True))
    f.WriteLine("1" & Chr(13))
    f.WriteLine("2" & Chr(13))
    f.WriteLine("3" & Chr(13))
    f.Close
 
Upvote 0
Also,

f.WriteLine("3" & CRLF) 'which is the shortcut for Chr(13)
 
Upvote 0
It also depends on which editor you use to read the file.
Using Notepad++ you will get separate lines, as that will take the LF at the end of the line as if it were CRLF.
Reading the file back in with f.ReadLine will read them as separate lines too.
 
Upvote 0
Back
Top