Solved

Insert Text

Posted on 2007-03-27
4
245 Views
Last Modified: 2010-04-23
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
Comment
Question by:thenrich
  • 2
4 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 125 total points
ID: 18801455
Hi thenrich;

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

Fernando
0
 
LVL 6

Expert Comment

by:riyazthad
ID: 18801469
try this

TextBox1.Text = TextBox1.Text.Substring(0, TextBox1.SelectionStart) & "Add " & TextBox1.Text.Substring(TextBox1.SelectionStart)
0
 
LVL 6

Expert Comment

by:CodeFish
ID: 18801476
Dim inStr As String = "This how"
        Dim modStr As String = " is"
        Dim endStr As String

        endStr = inStr.Insert(4, modStr)

Too Slow!
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 18801489
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now