|
-
Jul 9th, 2009, 05:09 PM
#1
Thread Starter
New Member
[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
Last edited by bbdevel; Jul 9th, 2009 at 05:44 PM.
-
Jul 9th, 2009, 05:53 PM
#2
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
Last edited by mickey_pt; Jul 9th, 2009 at 05:56 PM.
Reason: Code...
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Jul 9th, 2009, 05:55 PM
#3
Thread Starter
New Member
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? Would your way be easier? Thanks for your reply tho
Last edited by bbdevel; Aug 3rd, 2009 at 12:23 AM.
-
Jul 9th, 2009, 05:57 PM
#4
Re: CheckedListBox.Remove (*wildcard) or For each..
Why do you add, and then remove?
I think it's better to remove before add...
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Jul 9th, 2009, 06:05 PM
#5
Thread Starter
New Member
Re: CheckedListBox.Remove (*wildcard) or For each..
 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? Giving rep and marking resolved.
-
Jul 9th, 2009, 06:08 PM
#6
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.
Rate People That Helped You
Mark Thread Resolved When Resolved
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
|