Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
how can I replace text in richtextbox?
How can I replace TEXT in RichTEXT box??
I can not find to method in Richtexbox to replace TEXT?
Can anyone provide some coding?
8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
VB.net has introduced a number of changes to the way you access the RichTextBox's properties. SelUnderline, SelBold, SelStrikethrough etc are now available in the
property. For example, in VB.net, use
Dim strFind As String = "stringtofind"
Dim iPos As Integer = RichTextBox1.Find(strFind)
RichTextBox1.SelectedText = "stringtoreplace"
Your help has saved me hundreds of hours of internet surfing.
assuming the string you want to search in richtextbox1 is written in textBox1 and the button1 is the button which will tell you the index ...
set your richTextBox.HideSelection property to false( which is true by default) so that this code can show you the occurences of the required text..
Dim position As Integer = 0 ' in the declaration section of your form class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim index As Integer = RichTextBox1.Text.IndexOf(
ext, position)' get the index of next occurance
If (index > -1) Then' if the word is found
TextBox1.Text.Length) ' select and show the found text in the richtextbox
' You can also remove the line below to have the "FIND" Feature only instead of "FIND and REPLACE" feature
RichTextBox1.SelectedText = "New Word" 'put your word(s) that you want tyo replace
position = index + TextBox1.Text.Length 'update the position
MessageBox.Show("The string " & TextBox1.Text & " cannot be found")
Plans and Pricing
Certified Expert Program
© 1996-2022 Experts Exchange, LLC. All rights reserved. Covered by US Patent