I noticed a lot of queries / searches regarding saving text to a file and about formatting, but not the proper answer...
when you have a textbox and you save the contents to a file :
and you open the file in notepad, you will see instead of multiple lines one long line and where the vbNewLine should be, a small square symbol.
the simple reason is: even if you write a vbNewLine or vbCrLf to your textbox, it will be reduced to vbLf
so when writing the textbox.text to a textfile it only writes the vbLf where you would like to have a vbCrLf
so all you have to do is replace the vbLf with vbNewLine :
It puzzled me for a while, so I thought it might be handy to publish....
when you have a textbox and you save the contents to a file :
VB.NET:
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, TextBox1.Text, False, System.Text.Encoding.ASCII)
and you open the file in notepad, you will see instead of multiple lines one long line and where the vbNewLine should be, a small square symbol.
the simple reason is: even if you write a vbNewLine or vbCrLf to your textbox, it will be reduced to vbLf
so when writing the textbox.text to a textfile it only writes the vbLf where you would like to have a vbCrLf
so all you have to do is replace the vbLf with vbNewLine :
VB.NET:
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, Replace(TextBox1.Text, vbLf, vbNewLine), False, System.Text.Encoding.ASCII)
It puzzled me for a while, so I thought it might be handy to publish....