I am currently writing to a .txt file i would like to know how to add a 'return' function so when writing to the text file for it doesnt do this:
Testtesttesttesttesttest
But instead
Test
Test
Test
This is my current code (whilst i understand its basic its working so far)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
My.Computer.FileSystem.WriteAllText("F:\Documents\Documents\Visual Studio 2015\Projects\ExtentionLocator\ExtentionLocator\test.txt",
TextBox1.Text, True)
My.Computer.FileSystem.WriteAllText("F:\Documents\Documents\Visual Studio 2015\Projects\ExtentionLocator\ExtentionLocator\test.txt",
" ", True)
My.Computer.FileSystem.WriteAllText("F:\Documents\Documents\Visual Studio 2015\Projects\ExtentionLocator\ExtentionLocator\test.txt",
TextBox2.Text, True)
My.Computer.FileSystem.WriteAllText("F:\Documents\Documents\Visual Studio 2015\Projects\ExtentionLocator\ExtentionLocator\test.txt",
" ", True)
My.Computer.FileSystem.WriteAllText("F:\Documents\Documents\Visual Studio 2015\Projects\ExtentionLocator\ExtentionLocator\test.txt",
TextBox3.Text, True)
End Sub
The proper way to specify a line break is with Environment.NewLine
:
TextBox1.Text & Environment.NewLine
There are lots of ways to specify carriage returns and line feeds but the most correct way to specify a line break is with Envirnment.NewLine
. It will return the a String
containing the appropriate characters for the current system, which will be a carriage return and line feed pair on Windows (CR-LF, \r\n in C-based languages, ASCII 13 and 10) and a line feed alone on non-Windows systems.