So, I'm looping a readline function against blocks of text, and wish to detect when I've reached the end of my file.
A sample of two blocks of the text I'm parsing is below.
I'm using VS 2003
DATE: TUE 11/15/2005 4:21:48 PM
INITIALS: PRT
CMTAG: BLADE1
DEPARTMENT: SCU
CAMPUS: 22Maple
BUILDING: Bldg1
FLOOR: GRND
ROOM:
JACK:
LOC: SCU,22BRAM,BEAN,GRND,,
RC: SCU.NURSING.22BRAM.MMDORG
TYPE: Generic
DATE: TUE 11/15/2005 3:03:24 PM
INITIALS: PRT
CMTAG: BLADE2
DEPARTMENT: R6
CAMPUS: 24 East
BUILDING: Bldg3
FLOOR: 6
ROOM:
JACK:
LOC: R6,22BRAM,RICH,6,,
RC: NURSING.22BRAM.MMDORG
TYPE: Clinical
What I wish to do is, enable a search pattern that can search through the entire block of text, and if there's a match, write that block of text toa listbox.
So, th euser might search on "24 East", in which case I would want to write the ENTIRE block that contains that value.
So, my difficulty is in creating a way to search the whole block of text, or search each line IN a block, but keep the block together & write as needed.
see code below for what I have so far.
Confusing?
Thanks lads,
Rich
A sample of two blocks of the text I'm parsing is below.
I'm using VS 2003
DATE: TUE 11/15/2005 4:21:48 PM
INITIALS: PRT
CMTAG: BLADE1
DEPARTMENT: SCU
CAMPUS: 22Maple
BUILDING: Bldg1
FLOOR: GRND
ROOM:
JACK:
LOC: SCU,22BRAM,BEAN,GRND,,
RC: SCU.NURSING.22BRAM.MMDORG
TYPE: Generic
DATE: TUE 11/15/2005 3:03:24 PM
INITIALS: PRT
CMTAG: BLADE2
DEPARTMENT: R6
CAMPUS: 24 East
BUILDING: Bldg3
FLOOR: 6
ROOM:
JACK:
LOC: R6,22BRAM,RICH,6,,
RC: NURSING.22BRAM.MMDORG
TYPE: Clinical
What I wish to do is, enable a search pattern that can search through the entire block of text, and if there's a match, write that block of text toa listbox.
So, th euser might search on "24 East", in which case I would want to write the ENTIRE block that contains that value.
So, my difficulty is in creating a way to search the whole block of text, or search each line IN a block, but keep the block together & write as needed.
see code below for what I have so far.
Confusing?
Thanks lads,
Rich
VB.NET:
'Loop through the file until the end is reached
Do While Not myreader.Peek = -1
'Read the current line into the currentLine variable
currentLine = myreader.ReadLine
'Determine if any of the words the user would like
'to find are in the currentLine variable
'Before doing so however, store the currentLine in
'lower case letters to aid in searching (case sensitive)
lowerCaseLine = currentLine.ToLower
For Each word As String In wordsToSearchFor
If lowerCaseLine.IndexOf(word) Then
'Add this currentLine variable to your listbox
lb_1.Items.Add(currentLine)
'Don't bother searching for more words as one
'has already been found in this currentLine
Exit For
End If
Next
Loop