help me
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions 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.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
9 posts
Page 1 of 1
I didn't quite understand what your other topic was asking.
If you want the RichTextBox text to be replaced by the textbox text there is an easier way and that's
Can you be more specific about how the rtb is messing up? What exactly is it doing
If you want the RichTextBox text to be replaced by the textbox text there is an easier way and that's
Code: Select all
That just sets the RichTextBox's text to what ever is in the TextBox. RichTextBox1.Text = TextBox1.Text
Can you be more specific about how the rtb is messing up? What exactly is it doing
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
smashapps wrote:...If that doesn't work, try this:Code: Select all...RichTextBox1.Text = TextBox1.Text
Code: Select all
dim startText as String = "PageGate is an SMS messaging server application..."
Private Sub ReplaceText() Handles Button1.click
RichTextBox1.Text = startText.replace("PageGate", TextBox1.text)
End Sub
no no , when i do that (i mean the replacing) the richtextbox whole texts messing up
Find my programs on Softpedia
Code: Select all
Should bedim startText as String = "PageGate is an SMS messaging server application..."
Private Sub ReplaceText() Handles Button1.click
RichTextBox1.Text = startText.replace("PageGate", TextBox1.text)
End Sub
Code: Select all
because he is trying to replace all of rtb's text. dim startText as String = "PageGate is an SMS messaging server application..."
Private Sub ReplaceText() Handles Button1.click
RichTextBox1.Text = startText.replace(RichTextBox1.Text, TextBox1.text)
End Sub
Also it's hard for us to be helpful if we don't know exactly what the rtb is doing. Are you able to post a picture?
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
It is clear that if you are setting the Text property of the RichTextBox then all formatting will be lost. I presume this is the issue that you are facing?
You should use the SelectedText property to keep the formatting of the document/replaced text.
You should use the SelectedText property to keep the formatting of the document/replaced text.
Code: Select all
Private Sub btnReplace_Click(sender As System.Object, e As System.EventArgs) Handles btnReplace.Click
Dim toReplace As String = "test"
Dim index As Integer = RichTextBox1.Text.IndexOf(toReplace)
If index > -1 Then
RichTextBox1.Select(index, toReplace.Length)
RichTextBox1.SelectedText = "changed"
End If
End Sub
mandai wrote:It is clear that if you are setting the Text property of the RichTextBox then all formatting will be lost. I presume this is the issue that you are facing?can you please write the code for me ,
You should use the SelectedText property to keep the formatting of the document/replaced text.Code: Select allPrivate Sub btnReplace_Click(sender As System.Object, e As System.EventArgs) Handles btnReplace.Click Dim toReplace As String = "test" Dim index As Integer = RichTextBox1.Text.IndexOf(toReplace) If index > -1 Then RichTextBox1.Select(index, toReplace.Length) RichTextBox1.SelectedText = "changed" End If End Sub
i have a textbox and a richtextbox with bunch of texts and a buttons
for example
on the richtextbox there are 4-5 http://www.shimsoftwares.com by the way i want to replace all the http://www.shimsoftwares.com with textbox text when i click on the button dunnno;
Find my programs on Softpedia
It sounds like a replace all function would be useful. You can use this:
Code: Select all
Private Sub btnReplaceAll_Click(sender As System.Object, e As System.EventArgs) Handles btnReplaceAll.Click
Dim toReplace As String = "http://www.shimsoftwares.com"
again:
Dim index As Integer = RichTextBox1.Text.IndexOf(toReplace)
If index > -1 Then
RichTextBox1.Select(index, toReplace.Length)
RichTextBox1.SelectedText = TextBox1.Text
GoTo again
End If
End Sub
mandai wrote:It sounds like a replace all function would be useful. You can use this:thanks a lot #mandai , i dont know how to thank you hehaho;Code: Select allPrivate Sub btnReplaceAll_Click(sender As System.Object, e As System.EventArgs) Handles btnReplaceAll.Click Dim toReplace As String = "http://www.shimsoftwares.com" again: Dim index As Integer = RichTextBox1.Text.IndexOf(toReplace) If index > -1 Then RichTextBox1.Select(index, toReplace.Length) RichTextBox1.SelectedText = TextBox1.Text GoTo again End If End Sub
+rep
Find my programs on Softpedia
9 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023