The Student Room Group

Need some help with Visual Basic [AS COMPUTING]

Any pros at visual basic able to help me out?
i'd like to write to a text file using stream writer, im able to add data to the first line, however when i try to add data again it just changes the first line and i lose the first data i inputted, how do i get it so the new data im adding goes to the second line?
Reply 1
Share your code if you want help with it.
Reply 2
There's two ways to do this. First you read the content in and assign it to a variable. Then append your text to it then write it back out. Or... You could use the IO.File class which is great for IO related stuff. I personally love it.

It's this simple to read all your txt file.

Dim lines() As String = IO.File.ReadAllLines("mystuff.txt")

Quick Reply

Latest

Trending

Trending