Results 1 to 9 of 9

Thread: [RESOLVED] other methodes of "RTB.SelStart = Len(RTB.Text)"

  1. #1

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Resolved [RESOLVED] other methodes of "RTB.SelStart = Len(RTB.Text)"

    this code is working fine, but any other ways of doing this code?
    Code:
    Private Sub RTB_Change()
    RTB.SelStart = Len(RTB.Text)
    End Sub
    because its cursor will round back once and then go to the end of the sentence. it couse vertical scrool bar to go up and down.
    any idea? thanks for any help.

    Regards,

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: other methodes of "RTB.SelStart = Len(RTB.Text)"

    Don't know if it will be the answer, but an easy test.

    RTB.SelStart = Len(RTB.TextRTF)
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: other methodes of "RTB.SelStart = Len(RTB.Text)"

    try this
    Private Sub RTB_Change()
    RTB.Visible = false
    RTB.SelStart = Len(RTB.Text)
    RTB.Visible = true
    End Sub
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: other methodes of "RTB.SelStart = Len(RTB.Text)"

    Quote Originally Posted by ksuwanto8ksd
    this code is working fine, but any other ways of doing this code?
    Code:
    Private Sub RTB_Change()
    RTB.SelStart = Len(RTB.Text)
    End Sub
    because its cursor will round back once and then go to the end of the sentence. it couse vertical scrool bar to go up and down.
    any idea? thanks for any help.

    Regards,
    this code won't cause what you said. It must be caused by whatever is triggering this event in the first place. If you are overwriting the entire text of the textbox with new text it will reset the cursor to the beginning.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  5. #5

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Re: other methodes of "RTB.SelStart = Len(RTB.Text)"

    lavolve and isnoend07 your code have no diffrent with mine, thanks.
    Lord Orwell how do I prevent cursor from going back to the beginning ?.

    thanks for all replay

    Regards,

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: other methodes of "RTB.SelStart = Len(RTB.Text)"

    Maybe you should so us your code. Especially what happens before setting the cursor to the end of the RTB control.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: other methodes of "RTB.SelStart = Len(RTB.Text)"

    if you are appending text to the end of a rtb, there are two ways to do it:
    1.
    rtb.text = rtb.text + newtext

    and 2
    RTB.SelStart = Len(RTB.Text)
    rtb.seltext = newtext
    rtb.selstart = len(rtb.text)

    The problem with 1 is it resets the line position because what you are actually doing is erasing everything in the textbox and rewriting it again. You shouldn't expect the cursor to be in the same place when you are done.

    #2 appends text onto the existing text and you shouldn't have any problems with cursor position.

    There are more advanced methods of working with a rtb involving editing the .textrtf or the .selrtf properties but depending on your application they may not be necessary.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  8. #8
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: other methodes of "RTB.SelStart = Len(RTB.Text)"

    If you want new text on a new line then you can do

    rtb.selstart = len(rtb.text)
    rtb.seltext = vbnewline & newtext
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  9. #9

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