Results 1 to 2 of 2

Thread: How to detect cursor location and insert text???

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    6

    How to detect cursor location and insert text???

    If I have a rich text box on a form, that is filled with say 30 lines of text the user has inserted. Is there a way I can detect where the cursor is in that text and insert some pre-defined text at its location on a button click? For example:

    "This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box.<!!!!the cursor is here!!!> This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box."

    How can I detect where the cursor is and insert some text at its location? Thanks.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: How to detect cursor location and insert text???

    richTextBox.SelStart < - that's the cursor's current spot
    righTextBox.SelText = "Insert New Text" < - this inserts text at the richTextBox.SelStart location.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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