|
-
Mar 26th, 2010, 12:03 PM
#1
Thread Starter
Member
Do until match instead of endofstream
Code:
Dim xRead As StreamReader = New StreamReader(FilePath, System.Text.Encoding.Default)
Dim R As New Regex("""(.*)"",""" & MyTextbox.Text & "(.*)"",""(.*)"",.")
'read the file
Do Until xRead.EndOfStream
For Each M As Match In R.Matches(xRead.ReadLine)
MexIDResultTB.Text = M.Groups(1).Value
CompanyNameTB.Text = M.Groups(3).Value
Next
Loop
I need something like
Read the file line by line until a match is found then exit the loop
-
Mar 26th, 2010, 12:07 PM
#2
Re: Do until match instead of endofstream
You actually have to do both. It wouldn't be wise to not include something to end when the end of the stream is found, even if you are reasonably certain that there will always be a match.
Therefore, what you need to do is signal the loop that it is time to end. For instance, you could add a boolean variable outside of the loop, and when a match is found, set the variable to True. The loop would then be until either the variable is True OrElse the end of stream is found.
My usual boring signature: Nothing
 
-
Mar 26th, 2010, 12:08 PM
#3
Thread Starter
Member
Re: Do until match instead of endofstream
 Originally Posted by Shaggy Hiker
You actually have to do both. It wouldn't be wise to not include something to end when the end of the stream is found, even if you are reasonably certain that there will always be a match.
Therefore, what you need to do is signal the loop that it is time to end. For instance, you could add a boolean variable outside of the loop, and when a match is found, set the variable to True. The loop would then be until either the variable is True OrElse the end of stream is found.
Hello, Shaggy, could you give me an example please!?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|