Solved

Stupid VB RichTextBox question???

Posted on 2001-06-07
5
153 Views
Last Modified: 2010-05-02
I am writing a small program to display a data file on a machine.  The file is updated frequently so I am refreshing the file by loading it every 30 seconds in a richtextbox.  I need to have the text box automatically scroll to the bottom every time it loads so the user can see what data was added. Can anyone help me out with how to do that?  thanks,

 
0
Comment
Question by:halfback71
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 6164976
txtbox.selstart = len(txtbox.text)
0
 
LVL 7

Accepted Solution

by:
q2eddie earned 200 total points
ID: 6164977
Hi, halfback71.

#Try This
RichTextBox1.SelStart = Len(RichTextBox1.Text)
RichTextBox1.SetFocus

Bye. -e2
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6164978
Try

  RichTextBox1.SelStart = Len(RichTextBox1.Text)
  RichTextBox1.SelLength = 0
  RichTextBox1.Refresh

This will move the cursor to the bottom of the rich text box.
0
 
LVL 2

Expert Comment

by:Microsoft
ID: 6164997
build of this code


Private Type SCROLLINFO
    cbSize As Long
    fMask As Long
    nMin As Long
    nMax As Long
    nPage As Long
    nPos As Long
    nTrackPos As Long
End Type
Private Declare Function GetScrollInfo Lib "user32" (ByVal hwnd As Long, ByVal n As Long, lpScrollInfo As SCROLLINFO) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Const SIF_RANGE = &H1
Const SB_VERT = 1

Dim lHeight As Long, OnePixel As Long
Dim S As SCROLLINFO

Private Sub ScrollUp(delay As Long)
  Sleep delay
  With rtb1(0)
   .Top = .Top - OnePixel
   If .Top + .Height = 0 Then
      .Move 0, 0
      rtb1(1).Visible = False
   End If
   If .Top + .Height <= Picture1.Height Then
      rtb1(1).Top = .Top + .Height
      rtb1(1).Visible = True
   End If
  End With
End Sub

Private Sub Form_Load()
'CHANGE TO YOUR OWN FILE NAME
 rtb1(0).LoadFile App.Path & "\mydoc.rtf", rtfRTF
 Picture1.Move rtb1(0).Left, rtb1(0).Top, rtb1(0).Width, rtb1(0).Height
 Set rtb1(0).Container = Picture1
 OnePixel = Screen.TwipsPerPixelY
 S.cbSize = Len(S)
 S.fMask = SIF_RANGE
 Do
   Call GetScrollInfo(rtb1(0).hwnd, SB_VERT, S)
   If S.nMax = 0 Then Exit Do
   lHeight = S.nMax * OnePixel
   rtb1(0).Height = lHeight
 Loop
 If lHeight = 0 Then lHeight = rtb1(0).Height
 Text1 = lHeight / OnePixel
 rtb1(0).Move 0, 0
 Load rtb1(1)
 rtb1(1).Visible = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
  End
End Sub

'Using
'Private Sub Command1_Click()
'  Do
'    DoEvents
'    ScrollUp 50
'  Loop
'End Sub
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6165133
if you want to know how to make it so that it re-loads the file every 30 seconds do this:

put a timer on your form and set the interval to 3000 (30 seconds)

then put this code in your form module.

private sub timer1_timer()

    richtextbox1.loadfile "<path to file>"
    richtextbox1.selstart = len(txtbox.text)
    richtextbox1.setfocus
 
end sub

good luck
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question