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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Text To RichTextBox

Status
Not open for further replies.

jalbao

Programmer
Nov 27, 2000
413
US
How do I insert text at a specific location in a RichTextBox?

For example:

The text in my RTB is "The fox".

I would like to insert the string "quick brown " at index 5 of the existing string "The fox" so that the result will be "The quick brown fox".

Thanks
 
Untested:

Code:
public sub InsertText(iInsPoint as Integer, sInsString as String)
 rtBox.text = rtBox.text.substring(0,iInsPoint) & sInsString & rtBox.text.substring(iInsPoint+1,rtBox.text.lenght-(iInsPoint+1))
end sub

That should take the first half ("The ") of your text append your new text ("Quick Brown ") and then add the last half ("Fox")

-Rick

----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top