|
-
Mar 18th, 2009, 12:52 PM
#1
Thread Starter
New Member
Replace Text
OK... here is what I want to do...
If the user enters some text "abc", I want to have the app replace that text with something else during their data entry..
What I imagine is this:
Private Sub TextBox5_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox5.KeyDown
Dim cursorposition As String
Dim currentlinetext As String
If e.KeyCode = Keys.Space Then
cursorposition = TextBox5.SelectionStart()
currentlinetext = TextBox5.Lines(TextBox5.GetLineFromCharIndex(TextBox5.SelectionStart))
TextBox5.Text = TextBox5.Text.Replace(" 2w ", " 2 weeks ")
TextBox5.SelectionStart = cursorposition
However, the function only saves the cursor position from the original text length, so it does not return the cursor to the end of the replaced string.
One more thing... i do not necessarily was the cursor to go to the end of the textbox
Can anyone help???
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|