• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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?
0
thenrich
Asked:
thenrich
  • 2
1 Solution
 
Fernando SotoCommented:
Hi thenrich;

        Dim insertThisText As String = " Hello World "
        TextBox1.Text = TextBox1.Text.Insert(TextBox1.SelectionStart, insertThisText)

Fernando
0
 
riyazthadCommented:
try this

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

        endStr = inStr.Insert(4, modStr)

Too Slow!
0
 
Fernando SotoCommented:
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
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now