Results 1 to 6 of 6

Thread: [RESOLVED] Need help with strings

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member mbutler755's Avatar
    Join Date
    May 2008
    Location
    Peoria, AZ
    Posts
    417

    Resolved [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:
    1. ' Analyze button on original textbox
    2. ' Strips out the lines matching the items listed below in the keywords comment
    3. '
    4.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    5.         Dim OriginalFilePath As String = OriginalFileOpenFileDialog.FileName.ToString
    6.         Dim lines As New List(Of String)(IO.File.ReadAllLines(OriginalFilePath))
    7.         Dim searchtext As String = "Login"
    8.  
    9.         ' Keywords to strip out lines from the DEBOUT.TXT
    10.         Dim match = (From line In lines Where line.Contains("Login") _
    11.                      Or line.Contains("Username") Or line.Contains("Logout") _
    12.                      Or line.Contains("rpt") Or line.Contains("USERNAME") Select line).ToArray
    13.  
    14.         If match Is Nothing OrElse match.Length = 0 Then MsgBox("Nothing found") : Return
    15.  
    16.         For Each m As String In match
    17.             TextBox2.Text = "LINE " & lines.IndexOf(m).ToString & ": " & m & Environment.NewLine
    18.         Next
    19.     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
    Regards,

    Matt Butler, MBA, BSIT/SE, MCBP
    Owner, Intense IT, LLC
    Find us on Facebook
    Follow us on Twitter
    Link up on LinkedIn
    mb (at) i2t.us

    CODE BANK SUBMISSIONS: Converting Images to Base64 and Back Again

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
  •  



Click Here to Expand Forum to Full Width