StreamWriter question

teamdad

Member
Joined
Dec 31, 2003
Messages
12
I know I can use this code to write to a file with specific formats:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim writer As New IO.StreamWriter("C:\test.ini")
writer.Write(TextBox1.Text & " = " & TextBox2.Text)
writer.Flush()
writer.Close()


End Sub

But, how can I read the text from the file back into the orignal text boxes seperately like they were typed into in the first place by using a second button click?

P.S. I would like to have 2 coloms of text boxes ligned up one beside the other and 3 text boxes in each stack for a total of 6 text boxes. To make things more complicated; I would need the file when saved to have each line separate. The file should look like this when saved.

Text from box 1 = Text from box 2
Text from box 3 = Text from box 4
Text from box 5 = Text from box6


Any help with the proper code for both reading and writing like this is greatly appreciated by a newbie vb.net person.
 
declare a new streamreader object and use its read or readline properties
if you want to make sure the words come back formatted the way you want you should use the writeline and readline methods of the streamwriter and streamreader respectively

also you dont really need to call the flush method because when you close the file is flushed then

i hope that helps
brandon
 
Back
Top