Results 1 to 10 of 10

Thread: textbox cursor position?

  1. #1

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    textbox cursor position???
    i never needed to know this until now ...

    if i wanted to put text to a textbox all i would have to do was

    text1.text = "hello"

    and if i ever wanted to to put a line below that i would go

    text1.text = "hello" & vbcrlf & "world"

    however, now i need to insert words in the textbox with a command button ... i need it to insert the text where the blinking cursor is in the textbox ...

    can anyone help?

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196
    maybe if you explain more how/when this shouldhappen someone will be able to give you a better solution. For example, it can't happen after the user clicks on a button because the focus will no longer be with the textbox.

    what is the scenario or the event that triggers th need to insert text?

  3. #3
    Guest
    SelStart = Where the selection begins
    SelLength = How long is the selection
    SelText = What it contains

    Basically, you only need to set the SelText.

  4. #4

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    what i'm trying to do is a very simplistic html editor (if i can even call it that)

    its purpose is to make my coding a little faster.

    every time i might need to type <html> i just want to click on a command button and insert it wherever the blinking cursor is at ...

    i hope i explained myself better

  5. #5
    Guest
    Text1.SelText = " Hello"
    or
    Text1.text = Text1.text & " Hello"

  6. #6

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305

    thanks

    well that was really simple ... i thought it too simple to work so i didn't even bother to try that before ...

    1 more question ... which one would be more effecient ?

    Text1.SelText = " Hello"
    or
    Text1.text = Text1.text & " Hello"

  7. #7
    Guest
    Sorry for giving you a choice .

    Well, .SelText will overwrite any selected and put the new text.
    Whereas, Text1.text = Text1.text & ... will not overwrite any text, but will rather add to the textbox.

  8. #8
    Guest
    Text1.Text = Text1.Text & "Hello"

    isn't what you're looking for.


    Text1.SelText = "Hello"

    replaces the text that is selected in the textbox (if there's no selected text, it adds Hello to the current cursor position.


    If you wish to only add text, use

    Text1.SelText = Text1.SelText & "Hello"

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Nope, that's not really it either. Well what about this?
    Code:
        With Text1
            .SelStart = .SelStart + .SelLength
            .SelText = "Hello"
        End With
    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.

  10. #10
    Guest
    Uh, too many posts about the same thing I think?
    Anyway, do and use as you like theman32x.

    As a tip I can say that it's not good to add too many command buttons. You could make command buttons by category. When you click a button, you get a popup menu with the tags etc. that can be add to the HTML. It's simple to do and looks kinda cool

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