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

I tested the textbox and still same issue :(

Can you zip your entire project folder and post it here? I'll download it and see how it behaves on my computer.

'// 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

I don't think that's the problem because I did exactly what he posted and got the result he wanted.

Sorry to say but it works just fine on my computer. I really have no further ideas.

'// 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).

still same, will reboot then reply

on wordpad the issue doesn't exist even notepad exist, strange

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

Just for my own curiosity, is there any way you could post a hex dump of the saved output text file?

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.