Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert tags around selected text

Status
Not open for further replies.

guitardave78

Programmer
Sep 5, 2001
1,294
GB
Hey all :)

How can I put some tags around text selected in a text box?
I thought
Code:
Dim strSelText As String
strSelText = Me.txtNews.SelectedText.ToString
If (strSelText.Length) > 0 Then
   Me.txtNews.Text = Replace(Me.txtNews.Text.ToString, strSelText, "[b]" & strSelText & "[/b]", Me.txtNews.SelectionStart, 1)
End If

may do it but no luck!!

}...the bane of my life!
 
Try using:

Code:
If Me.txtNews.SelectionLength > 0 Then
   Dim txt As String = Me.txtNews.SelectedText

   Me.txtNews.SelectedText = "..." & txt & "..."
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top