Results 1 to 3 of 3

Thread: adding text to text

  1. #1

    Thread Starter
    Hyperactive Member New to VB 6's Avatar
    Join Date
    Apr 2002
    Posts
    362

    Question 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]

  2. #2
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    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:
    1. Private Sub Form_Load()
    2.     rtb1.Text = "Forescore and seven years ago our forefathers, blah, blah, blah"
    3. End Sub
    4. Private Sub Command1_Click()
    5.     rtb1.SelText = "Hello World"
    6. 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!

  3. #3
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    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
  •  



Click Here to Expand Forum to Full Width