|
-
Dec 7th, 2002, 08:25 PM
#1
Thread Starter
Hyperactive Member
adding text to text
I have an app where I click a button and it inserts text in to a richtextbox, I can add the text at the end. but I want to know is how do I add text to the file at the point where the cursor is
i.e.
for all intents and purposes | will stand for the cursor
this that and the | thing
after the button it will say
this that and the other| thing
[VBCODE]
Option Explicit
Dim XXX As Porn
Dim Wife As Nag
Private Sub *****_Resize()
On Error Resume Next
Get Viagra
End Sub
[/VBCODE]
-
Dec 7th, 2002, 08:49 PM
#2
Fanatic Member
Here is a real basic example. Run this, click somewhere in the middle of the sentence, then click command 1. It will insert "Hello World" at the cursor position. If you had a section higlighted, it would replace the highlighted text.
Hope this gives you a start . . .
VB Code:
Private Sub Form_Load()
rtb1.Text = "Forescore and seven years ago our forefathers, blah, blah, blah"
End Sub
Private Sub Command1_Click()
rtb1.SelText = "Hello World"
End Sub
"Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!
Resistance is futile, you will be compiled . . . Please!
-
Dec 7th, 2002, 11:32 PM
#3
The other way is to use the Sendkeys command after clicking to position the cursor to insert text. this simulates you typing the characters from the keyboard.
Sendkeys "What ever your text is"
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
|