[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
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