Results 1 to 2 of 2

Thread: [RESOLVED] [2008] Loop Txtfiles in CheckedListBox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2008
    Posts
    92

    Resolved [RESOLVED] [2008] Loop Txtfiles in CheckedListBox

    Greetings
    what iam trying to do is loop thru a checkedlistbox i open a file and theres text files in the checkedlistbox all checked, want to search thru all text files adding all found items in lstListBox1.Items.Add(m.Value)
    i can do 1 file at a time , below is some code i been working with
    Thank you for any help on this.

    Code:
    Dim options As RegexOptions = RegexOptions.Multiline
    
            Dim testStr As String = IO.File.ReadAllText(openFileDialog1.FileName)
    
            
            Dim rx1 As New Regex(" My regex here")
    
            Dim n As Integer = testStr.Count
            'CheckedListBox1
            
            For n = 0 To (CheckedListBox1.Items.Count - 1)
                If CheckedListBox1.GetItemChecked(n) = True Then
    
                   
                    MsgBox(CheckedListBox1.CheckedItems.Item(n))
    
    
    
    
                    For Each m As Match In rx1.Matches(testStr)
    
                        lstListBox1.Items.Add(m.Value)
    
                    Next
                End If
    
            Next
    Best,Regards

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: [2008] Loop Txtfiles in CheckedListBox

    I think it needs to be more like this

    Code:
            Dim testStr As String
            Dim rx1 As New Regex(" My regex here", RegexOptions.Multiline)
    
            For n As Integer = 0 To (CheckedListBox1.CheckedItems.Count - 1)
                testStr = IO.File.ReadAllText(CheckedListBox1.CheckedItems(n).ToString)
                For Each m As Match In rx1.Matches(testStr)
                    lstListBox1.Items.Add(m.Value)
                Next
            Next

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