Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I use the following code to write individual lines into a text file:

 

Dim m_strTestFile As String = "c:\test.txt"

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

Dim writer As New IO.StreamWriter(m_strTestFile)

 

writer.Write(TextBox1.Text & vbCrLf)

writer.Write(TextBox2.Text & vbCrLf)

writer.Write(TextBox3.Text & vbCrLf)

writer.Write(TextBox4.Text & vbCrLf)

writer.Flush()

writer.Close()

 

End Sub

 

The test.text file looks like this with the text that has been typed in the boxes.

 

Text Box Line 1

Text Box Line 2

Text Box Line 3

Text Box Line 4

 

If say the boxes were reset and did not have text in them any longer, how can I use the IO.StreamReader to recall the individual lines back into the text boxes they were written in originally with another button click? Would it be easier to use an xml format and if so could someone give an example of both read and write to get me started in that direction?

 

Thanks in advance

  • Leaders
Posted

Seems like you should only have to create a System.IO.StreamReader and then

TextBox1.Text = SR.ReadLine()

TextBox2.Text = SR.ReadLine() ...

:)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

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...