TextBox1 = TextBox1 & NewText
the scroll bar reverts to the upper-most position
how to keep the scroll bar in its previous location ?
how to force scroll bar to bottom position ?
Text1.Selstart = Len(Text1.text)
- David Serrano
http://www.delos.net/btmsoftware/
"It's Great To Be Alive, Have a Wonderful day"
Forcing the textbox to stay at the bottom is easy, just do something like:
Private Sub Text1_Change()
Text1.SelStart = Len(Text1.Text)
End Sub
Getting the textbox to maintain the same position is also fairly simple, but
requires a couple more lines of code:
'in the general declarations
Option Explicit
Dim TxtPos As Integer
'I'm using a command button to simulate the event that adds text to the
'textbox, but you can place this code in whatever event you like
Private Sub Command1_Click()
TxtPos = Text1.SelStart
Text1.Text = Text1.Text & "Hello"
Text1.SetFocus
End Sub
Private Sub Text1_Change()
Text1.SelStart = TxtPos
End Sub
Hope this helps.... :)
--
Sheppe Pharis
VB5/ActiveX Developer
http://www.riot.bc.ca/2mVB
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
To help prevent this, I use the following code:
With Text1
.SelStart = len(Text1.Text) ' move to end of text
.SelText = "Hello" ' This will add the text at the
current position (i.e. the end of the box)
.SelStart = len(Text1.Text) ' or previous position if so required.
End With
This code doesn't cause the textbox to move back up to the top of the text.
Roger Bucks
she...@rogersfoods.com wrote in message <746gof$7bn$1...@nnrp1.dejanews.com>...