Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Stupid VB RichTextBox question???

Posted on 2001-06-07
5
Medium Priority
?
157 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 800 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

618 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