|
-
Apr 25th, 2010, 10:49 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Need help with strings
I am building a program that strips out certain keywords from a much larger file. I am using code that .paul. provided in a different post, but I can't get it to work correctly. Here is the code that I am using:
vb.net Code:
' Analyze button on original textbox
' Strips out the lines matching the items listed below in the keywords comment
'
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim OriginalFilePath As String = OriginalFileOpenFileDialog.FileName.ToString
Dim lines As New List(Of String)(IO.File.ReadAllLines(OriginalFilePath))
Dim searchtext As String = "Login"
' Keywords to strip out lines from the DEBOUT.TXT
Dim match = (From line In lines Where line.Contains("Login") _
Or line.Contains("Username") Or line.Contains("Logout") _
Or line.Contains("rpt") Or line.Contains("USERNAME") Select line).ToArray
If match Is Nothing OrElse match.Length = 0 Then MsgBox("Nothing found") : Return
For Each m As String In match
TextBox2.Text = "LINE " & lines.IndexOf(m).ToString & ": " & m & Environment.NewLine
Next
End Sub
Basically, the first match will appear in textbox2, but no other matches appear after that. I put a breakpoint at the For Each loop and checked out the locals. I am showing 2,502 matches for the variable "match." I just now put another breakpoint in there and I can see that it is stepping, but nothing is recorded. Any help is much appreciated.
In the archive is a file named debout.txt. This file should be used for the testing.
Last edited by mbutler755; Apr 25th, 2010 at 11:33 AM.
Reason: removed archive of the program
Tags for this Thread
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
|