M. Nicholas
New member
- Joined
- May 7, 2006
- Messages
- 2
- Programming Experience
- Beginner
Hello,
I’m trying to create a program will supply information for variables from a text file, so that as the possibilities change, a simple text file will need to be amended, rather than rewriting the original code. I am reading about FileStream and StreamReader, which seem like just the ticket.
For instance, if I wanted to populate a TextBox with items I wrote in a text file, such as:
Tom
Mike
Jim
Jean
I threw together a sub like this:
------------------------------
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim objFS As FileStream
Dim objSR As StreamReader
Dim TextSays As String
objFS = New FileStream("C:\test\test.txt", FileMode.Open, FileAccess.Read)
objSR = New StreamReader(objFS)
TextSays = objSR.ReadToEnd
objSR.Close()
TextBox1.Text = TextSays
End Sub
------------------------------
This works perfect. Now, I need the ability to categorize my text file. For instance:
[my family start]
Tom
Mike
Jim
Jean
[my family end]
[your family start]
Bob
Dave
Ted
Steve
[your family end]
I am trying to figure out how to tell the streamreader to start reading in one category, and finish reading at the end of that category. My end result will be a form that I design to have every possible category available on the form, but the items listed for each category to be easily changed or added to by the end user via a simple text file.
Any suggestions would be appreciated
I’m trying to create a program will supply information for variables from a text file, so that as the possibilities change, a simple text file will need to be amended, rather than rewriting the original code. I am reading about FileStream and StreamReader, which seem like just the ticket.
For instance, if I wanted to populate a TextBox with items I wrote in a text file, such as:
Tom
Mike
Jim
Jean
I threw together a sub like this:
------------------------------
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim objFS As FileStream
Dim objSR As StreamReader
Dim TextSays As String
objFS = New FileStream("C:\test\test.txt", FileMode.Open, FileAccess.Read)
objSR = New StreamReader(objFS)
TextSays = objSR.ReadToEnd
objSR.Close()
TextBox1.Text = TextSays
End Sub
------------------------------
This works perfect. Now, I need the ability to categorize my text file. For instance:
[my family start]
Tom
Mike
Jim
Jean
[my family end]
[your family start]
Bob
Dave
Ted
Steve
[your family end]
I am trying to figure out how to tell the streamreader to start reading in one category, and finish reading at the end of that category. My end result will be a form that I design to have every possible category available on the form, but the items listed for each category to be easily changed or added to by the end user via a simple text file.
Any suggestions would be appreciated