Textbox/Rich Textbox

Getox

Centurion
Joined
Jul 8, 2004
Messages
122
I have a Rich textbox and have some text in it, What im trying to do is when the user selects text and clicks a button it will replace that selected text with something like <tag>{selected text}</tag> How would i do this?


EDIT--------------------------------------------------------------------
Ok well i got what i wanted after playing around with the code for a while,

Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        codebox.Copy()
        tmptext.Paste()
        formattext.Text = "<b>" + tmptext.Text + "</b>"
        formattext.Select()
        formattext.Copy()
        codebox.Paste()
        formattext.Clear()
        tmptext.Clear()
    End Sub

But if anyone knows a better way, Please do tell me.
 
Last edited:
Oh thats great, theres a heap of code replaced by 1 line of code :)

I edited it a bit heres the code:
codebox.SelectedText = "<b>" + codebox.SelectedText + "</b>"
 
Back
Top