Change text in a text box

M

Marco

Hello.

I want to make some changes in the selected text in a text box.

Imagine that I have this text in a text box:
"The Web Server may be down, too busy, or experiencing other problems
preventing it from responding to requests. You may wish to try again at a
later time. "

Imagine that I select some part of text and in the selected area I want to
add the folowing codes: <b> </b>

In the example, imagine that I select "Web Server", I want to press a button
and add the codes to that text in order to get this:

"The <b>Web Server</b> may be down, too busy, or experiencing other problems
preventing it from responding to requests. You may wish to try again at a
later time. "

Please help,
Marco
 
D

Damon Heron

Use the mouseup event.

Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single,
Y As Single)
Dim strvar As String
strvar = Me.Text1.SelText
Me.Text1 = Replace(Me.Text1, strvar, "<b>" & strvar & "</b>", 1, 1,
vbTextCompare)
End Sub

This can get real messy, and you will need to click somewhere outside the
textbox after each change --so a cmdbutton to reset the text to the original
might be needed.

Damon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top