Click here to Skip to main content
14,774,467 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
How do you remove words that appear like this:

I received aa bad advice a bad suggestion

I want it to look like this from the RichTextBox:

I received a bad suggestion

These words come from my Listbox.

How do I remove words that have been copy/pasted from the ListBox? My listBox is divided into two columns, the Bad words and Good words. The Bad words are those that look like this: a bad advice, while the Good words are those that look like this: a bad suggestion. There are many so when writing, you can find many.
Posted
Updated 16-Nov-15 10:06am
v2
Comments
Dave Kreskowiak 16-Nov-15 14:14pm
   
That makes no sense at all. We have no idea what you're trying to do. You're going to have to hit the "Improve question" widget and provide an example of what you're looking for.
[no name] 16-Nov-15 15:07pm
   
I have edited the code, so I hope its better now.
[no name] 16-Nov-15 15:27pm
   
What I want it to remove the duplicate word like aa or comecome from where they happen upto the end of the empty spaces which is here: a bad suggestion from here:

I received aa bad advice a bad suggestion

[no name] 16-Nov-15 15:07pm
   
Please reply!
Dave Kreskowiak 16-Nov-15 23:05pm
   
Sorry, but I don't work for you. I have my own job that I have to do and meetings to attend. I also have a life to attend to. I answer questions on MY TIME, whenever I have time available, not when you demand.

If you have a list of "bad words", whatever that means, it's a simple matter of search and replace. This is simple string manipulation. Read the documentation on the String class and it's methods for what you can do with it.
Sergey Alexandrovich Kryukov 16-Nov-15 15:26pm
   
Your post is full of bad words. Then need replacement. :-)
Please replace them with those which explain some real problem.
—SA
[no name] 16-Nov-15 16:12pm
   
It is a RichTextBox not a List. The words are suggested by the ListBox from its two columns with Bad words that shows the program knows what the user is talking about, and my suggestions which is the Good words.

If I understand your question correctly you are attempting to remove curse words (ex 'sh*t', 'bi^ch', etc.) from a RichTextBox and replace them with something more user friendly. I can agree (to a point) with some of the other comments in this post you should really try actually learning something from the programming experience and not expect the community to do your work for you. To actually attempt and help guide you instead of judge you for your lack of knowledge here are a few links you should really look at to get you started on your current task.

https://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.text(v=vs.110).aspx[^]

string replace[^]

https://msdn.microsoft.com/en-us/library/system.string.replace(v=vs.110).aspx[^]
   
try :
for each str as string in *your text*
 for each str2 as string in *your List*
if(str=str2) Then
yourtext.replace(str,"")
End if
Next
Next
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900