You can try this:
Code:Option Explicit Private Declare Function SendMessage _ Lib "user32.dll" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByRef lParam As Any) As Long Private Const EM_GETFIRSTVISIBLELINE As Long = &HCE Private Const EM_LINESCROLL As Long = &HB6 Public Sub SetTopIndex(rtb As RichTextBox, ByVal nLine As Long) Dim nIndex As Long nIndex = nLine - SendMessage(rtb.hwnd, EM_GETFIRSTVISIBLELINE, 0&, 0&) Call SendMessage(rtb.hwnd, EM_LINESCROLL, 0&, ByVal nIndex) End Sub Private Sub Form_Load() rtb.Text = "" rtb.SelText = "This is a text, this is only a text test, which is long" SetTopIndex rtb, 0 End Sub




If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!
Reply With Quote
