[RESOLVED] CheckedListBox.Remove (*wildcard) or For each..
Ive searched high and low and can not come up with a solution..maybe Im just using the wrong search string...any help would be great. Basically I have read a txt file line by line split with regex all works well except blank space so I .remove("") blank line. Now I need to further remove all strings that start with prefix of PREFIX_somefile. Thanks for any help!
Code:
Dim str As String
For Each str In strs
CheckedListBox1.Items.Add(str)
CheckedListBox1.Sorted = True
CheckedListBox1.Items.Remove("")
CheckedListBox1.Items.Remove("PREFIX_"*wildcard)
Next
Re: CheckedListBox.Remove (*wildcard) or For each..
Just use the str.contains("PREFIX_") to compare and remove that line...
The code
VB.NET Code:
Dim str As String
For Each str In strs
If str.Contains("PREFIX_") OrElse str.Length = 0 Then
Continue For
End If
CheckedListBox1.Items.Add(str)
CheckedListBox1.Sorted = True
Next
Re: CheckedListBox.Remove (*wildcard) or For each..
Code:
Dim itemText As String
For i As Integer = (CheckedListBox1.Items.Count - 1) To 0 Step -1
itemText = CheckedListBox1.GetItemText(CheckedListBox1.Items(i))
If itemText.StartsWith("PREFIX_") Then
CheckedListBox1.Items.RemoveAt(i)
End If
Next
This works perfect do you recommend this code? :D Would your way be easier? Thanks for your reply tho
Re: CheckedListBox.Remove (*wildcard) or For each..
Why do you add, and then remove?
I think it's better to remove before add...
Re: CheckedListBox.Remove (*wildcard) or For each..
Quote:
Originally Posted by
mickey_pt
Why do you add, and then remove?
I think it's better to remove before add...
I think your right too! Thanks for your help! Your code works too! Wouldn't know how to make a function key for app with no button? :D Giving rep and marking resolved.
Re: [RESOLVED] CheckedListBox.Remove (*wildcard) or For each..
Thanks
But i don't understand what you trying to do, and if this is another question just create a new thread and mark this one resolved.