Results 1 to 6 of 6

Thread: Inserting text into a text box

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    New Orleans, LA
    Posts
    37
    I have a small project im working on and i cant seem to figure out one thing, how do i insert text AT THE CURSOR into a text box.

    simple example:

    lets say i have a text box that reads:

    "Hello, welcome to my program!"

    and the cursor is right betwteen the word Hello and the comma, and i want a button that will insert text at the cursor (such as a name in this instance).

    i know it will involve breaking the text box contents into a string before the cursor point and a string after the cursor point then sticking a string in between and cancatonating it all together but i cant figure out how to get the cursor position.

    any help would be appreiciated, thanks in advance'

    -glitch13

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    'to insert text at the cursor position
    text1.seltext = text1.seltext & "some text here"
    'to get the cursor position
    debug.print text1.selstart
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    New Orleans, LA
    Posts
    37
    havent been able to try it yet, but even though you dont have all the text up to the cursor selected, VB still sees all the text before the cursor as selected text?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    It automatically deselects if you use seltext
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    New Orleans, LA
    Posts
    37
    sorry, i misstyped, i meant

    even thought you DON'T have all of the text up to the cursor selected it still sees all of the text up to the cursor as selected text?

    if you misanswered the first time, let me reiterate:

    pretend that the "|" is the cursor, i want the following:


    "Hello|, welcome to my program!"

    to read:

    "Hello John, welcome to my program"

    (not the mouse cursor, the text edit cursor)

    [Edited by glitch13 on 11-11-2000 at 07:33 PM]

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    That's exactly what it should do, go try it for yourself
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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