Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

declare a new streamreader object and use it's 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 don't really need to call the flush method because when you close the file is 'flushed' then

 

i hope that helps

brandon

i'm not lazy i'm just resting before i get tired.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...