Replace Code

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
8 posts Page 1 of 1
Contributors
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Replace Code
GoodGuy17
Hello,
I need to know how to replace all occurrences of text that the user specified.
Example:
I click replace, window pops up. It says Find What and Replace With. I type Jim in Find and Bob in replace. I have Jim in 5 different places in my text. Different lines maybe, who knows. I click replace, and it changes every Jim in the RichTextBox to Bob. And I need the code for the Tabbed version too.
Early thanks to any helpers!
P.S. You will be put in my credits box if wanted.
~GoodGuy17 :D
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Replace Code
mandai
Try:
Code: Select all
RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("old", "new")
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Replace Code
Codex
or you can just have
Code: Select all
RichTextBox1.Rtf.Replace("Jim", "Bob")
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Replace Code
zachman61
i think livengood made a tutorial for this
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Replace Code
Lewis
codeXvideos wrote:
or you can just have
Code: Select all
RichTextBox1.Rtf.Replace("Jim", "Bob")

Incorrect i tried that before and it diddnt work.
Image
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Replace Code
zachman61
would text work instead of rtf
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Replace Code
mandai
Text will work but it may remove any formatting used in the rtf document.
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Replace Code
zachman61
oh i see
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
8 posts Page 1 of 1
Return to “Tutorial Requests”