Hey everyone. I'm currently trying to figure out how to use the StreamReader and ReadAllLines functions of VB.NET to search a text file for keywords and pull the information that follows those keywords. To elaborate more, I have a PDF which I convert to text and once converted, the text file has a block that reads as follows:
DATE: May 21, 2015
DAILY REPORT
LOCATION NO: 12345 SHOW ID: CRT-0115-0113
USER: Rod Serling INQUIRY NO: 2015-900-0000
Now, the text file continues on with a description but this is the only block I'm concerned about. My idea is to have the StreamReader read the entire file until the end while looking for keywords "Date:", "LOCATION NO:", "USER:", "SHOW ID:", and "INQUIRY NO:". When it hits those, it pulls the information that follows it into a corresponding textbox. My trouble is that I'm having a hard time working out the logic for this problem being fresh to VB.NET.
I understand that I want to initialize the IO.StreamReader, have it read the entire file. I also have to declare a variable and make that my tool for looking for the keywords. Something along the lines of:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Reader As New IO.StreamReader("C:\" & TheFileName.Text & ".txt") 'This will allow me to type in name of file in txtbox
Dim line AS String 'Read my whole file
Do
line = Reader.ReadLine()
Dim K as Integer=line.IndexOf("Insert my keywords here")
'And it all falls apart on me on what to do after this.
End Sub
Any help or pointing to tutorials on this would be greatly apperciated.