[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,
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)
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
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.
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,
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.
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.
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
Re: other methodes of "RTB.SelStart = Len(RTB.Text)"
thanks for all help, this dont couse serious problem.