Hello,

Im newbie at VB and i need help solving my issue please

The code i used:

Dim SaveFile As New SaveFileDialog
            SaveFile.FileName = ""
            SaveFile.Filter = "Text Files (*.txt)|*.txt"
            SaveFile.Title = "Save"
            SaveFile.ShowDialog()
            Try
                Dim Write As New System.IO.StreamWriter(SaveFile.FileName)
                Write.Write(RichTextBox1.Text)
                Write.Close()
            Catch ex As Exception
            End Try

The problem is that when i save the text file

It be from

A
B
C
D
E
F

TO ONE LINE

ABCDEF

Hope someone could help me, thanks in advance

I set up a test exactly as you specified and my text file contains

A
B
C
D
E
F

Can you possibly post a screenshot of your app running?

I usually use TextPad instead of Notepad and I have seen multiple lines display as one in notepad when the lines end with a line feed only rather than carriage return+line feed. TextPad doesn't have this problem. What happens if you list the contents of the file from the command line (using the TYPE command)?

looks like the issue from the richtextbox, i will give a try for textbox and then reply

'// TextBox.
        IO.File.WriteAllText("full.path of file here", TextBox1.Text)
        '// RichTextBox.
        RichTextBox1.SaveFile("full.path of file here", RichTextBoxStreamType.RichText) '// change ".RichText" to ".PlainText" If needed.

Also, check if btnOk has been clicked before saving.

If SaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
            '// save :)
        End If

Edited 4 Years Ago by codeorder: '// save :)

'// TextBox.
        IO.File.WriteAllText("full.path of file here", TextBox1.Text)
        '// RichTextBox.
        RichTextBox1.SaveFile("full.path of file here", RichTextBoxStreamType.RichText) '// change ".RichText" to ".PlainText" If needed.

Also, check if btnOk has been clicked before saving.

If SaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
            '// save :)
        End If

Sorry but where should i put those codes?

With New SaveFileDialog
            .Filter = "Text Files (*.txt)|*.txt"
            .Title = "Save"
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                IO.File.WriteAllText(.FileName, TextBox1.Text)
                '// RichTextBox.
                'RichTextBox1.SaveFile(.FileName, RichTextBoxStreamType.RichText) '// change ".RichText" to ".PlainText" If needed.
            End If
        End With

If you still have this issue(should Not), reboot your system(could be an internal bug that needs to be squashed).

Thanks for input.
If thread solved, mark as Solved; best of luck and welcome to the forum.:)

Edited 4 Years Ago by codeorder: n/a

Well i solved it with the textbox but with the richtextbox not yet...

The new code is

Dim SaveFile As New SaveFileDialog
            SaveFile.FileName = ""
            SaveFile.Filter = "Text Files (*.txt)|*.txt"
            SaveFile.Title = "Save"
            SaveFile.ShowDialog()
            Try
                Dim Write As New IO.StreamWriter(SaveFile.FileName)
                Write.Write(TextBox1.Text)
                Write.Close()
            Catch ex As Exception
            End Try
This question has already been answered. Start a new discussion instead.