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.
9 posts Page 1 of 1
Contributors
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

help me
Shim
hello guys :)

so i last asked helped about ... viewtopic.php?f=21&t=10173

so when i do that the richtextbox whole text messing up i

s there any way to keep the richtextbox calm without messing ?
Find my programs on Softpedia
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: help me
smashapps
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
Code: Select all
RichTextBox1.Text = TextBox1.Text
That just sets the RichTextBox's text to what ever is in the TextBox.

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!
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

Re: help me
Cheatmasterbw
smashapps wrote:
...
Code: Select all
RichTextBox1.Text = TextBox1.Text
...
If that doesn't work, try this:
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
http://www.megaapps.tk/
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: help me
Shim
no no , when i do that (i mean the replacing) the richtextbox whole texts messing up
Find my programs on Softpedia
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: help me
smashapps
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
Should be
Code: Select all
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
because he is trying to replace all of rtb's text.

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!
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: help me
mandai
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.
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
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: help me
Shim
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?

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
can you please write the code for me ,

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
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: help me
mandai
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
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: help me
Shim
mandai wrote:
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
thanks a lot #mandai , i dont know how to thank you hehaho;

+rep
Find my programs on Softpedia
9 posts Page 1 of 1
Return to “Coding Help & Support”