Link to home
Start Free TrialLog in
Avatar of thenrich
thenrich

asked on

Insert Text

How can I insert a peace of text into a text box at the current cursor location vs. apending to the end of the text string?
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of riyazthad
riyazthad

try this

TextBox1.Text = TextBox1.Text.Substring(0, TextBox1.SelectionStart) & "Add " & TextBox1.Text.Substring(TextBox1.SelectionStart)
Dim inStr As String = "This how"
        Dim modStr As String = " is"
        Dim endStr As String

        endStr = inStr.Insert(4, modStr)

Too Slow!
Hi thenrich;

The above code will insert text into TextBox1 where the text insertion point is in the text box, not where the cursor is. So you will need to click to set the insertion point..

Fernando