Click to See Complete Forum and Search --> : Making A Textbox scroll to the bottom on every update
February 2nd, 2000, 07:10 AM
Hi my name is Will and I am having a problem with a rich text box in my program. You see, I am working on an encryption and then I want to decrypt the text and put it into a text box. But the text can be larger than the text box so I have scroll bars. But every time I want the user to be able to update it, the text box starts from the top and they have to keep scrolling down and that can get very boring after a while. So what I need is to be able to make the text box scroll all the way to the bottom when it has a changed event. A good analagy would be AOL's IM's. They always scroll to the bottom when someone sends a message. Thank you for your help. It will be greatly appreciated!
-Will
JimmyT
February 2nd, 2000, 07:18 AM
Try this
private Sub RichTextBox1_Change()
RichTextBox1.SelStart = len(RichTextBox1.Text)
RichTextBox1.SelLength = 1
End Sub
This selects the last character of the textbox which forces a scroll to the bottom of the document.
Good Luck
February 2nd, 2000, 07:25 AM
I'm not really sure if this is what you want to acheive but if all you want to do is set the curson position to be that of the last character in the rich text box then just use the send keys function
ie
richtext1_change()
SendKeys "^{END}"
end sub
the only problem with this is that if a user starts typing at the end of your text then the computer beeps but this can be stoppen by using the following
CONSTANT and FUNCTION
private Const SPI_SETBEEP = 2
private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (byval uAction as Long, byval uParam as Long, byref lpvParam as Any, byval fuWinIni as Long) as Long
and then calling where ever you want
Call SystemParametersInfo(SPI_SETBEEP, false, 0, 0)
recalling it with false set to true turns the beep back on
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.