Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Create new line when writing to a txt file

$
0
0
How would I add a new line to the textfile, instead of erasing everything I currently have


here is my current code

        Dim inputData As String


        inputData = InputBox("Enter what to save")

        Dim FILE_NAME As String = "C:\Users\Ben\Documents\Vb.netshiz\learninggoal.txt"

        If System.IO.File.Exists(FILE_NAME) = True Then

            Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

            objWriter.WriteLine(vbNewLine & inputData)
            objWriter.Close()
            MsgBox("Text written to file")

        Else

            MsgBox("File Does Not Exist, being created now")
            Dim writeFile As IO.StreamWriter
            writeFile = IO.File.CreateText(FILE_NAME) 'Creates a new file
            writeFile.WriteLine(inputData)
            writeFile.Close()




        End If







Feel free to fix up the code also if you want, because I know it's messy :P

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>