Results 1 to 4 of 4

Thread: Scroll text from bottom of RTB

  1. #1

    Thread Starter
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Scroll text from bottom of RTB

    I am trying to add text one line at a time to a richtextbox.
    I would like the new line to be added to the bottom of the RTB and the previous line to be moved up a line, to give the appearance of the text scrolling up to the top.

    So far I have the following:

    Code:
    Private Sub Form_Load()
    Dim myString As String
    Dim tmpArray() As String      
    
    myString = "First line of text" & vbCrLf & vbCrLf & _
                    "Second line of text" & vbCrLf & vbCrLf & _
                    "Third line of text" & vbCrLf & _
                    "Fourth line of text"
                    
    tmpArray() = Split(myString, vbCrLf)  
    
    Timer1.Enabled = True
    
    End Sub
    
    Private Sub Timer1_Timer()
    Dim i As Long
    
    For i = 0 to Ubound(tmpArray)
         RichTextBox1.Textrtf = RichTextBox1.rtf & vbcrlf & tmpArray(i)
    Next i
    I am guessing it's something to do with the timer code.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Scroll text from bottom of RTB

    there are some declaration issues i saw,
    fixed them.

    Code:
    Private i As Long
    Private tmpArray() As String
    Code:
    Private Sub Form_Load()
    Dim myString As String
    
    myString = "First line of text" & vbCrLf & vbCrLf & _
                    "Second line of text" & vbCrLf & vbCrLf & _
                    "Third line of text" & vbCrLf & _
                    "Fourth line of text"
                    
    tmpArray() = Split(myString, vbCrLf)
    
    Timer1.Enabled = True
    
    End Sub
    Code:
    Private Sub Timer1_Timer()
    For i = 0 To UBound(tmpArray)
        RichTextBox1.TextRTF = RichTextBox1.Text & vbCrLf & tmpArray(i)
    Next i
    End Sub
    Edited.
    Last edited by Fazi; Oct 21st, 2007 at 07:05 AM.

  3. #3
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Scroll text from bottom of RTB

    akido, to insert a line to the top, you can do like this
    Code:
    Me.RichTextBox1.Text = "Hai" & vbCrLf & Me.RichTextBox1.Text

  4. #4

    Thread Starter
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: Scroll text from bottom of RTB

    Thanks Fazi,

    I have completely reworked this.
    I now have the RTB inside of a picturebox and in the timer I set the top value of the RTB to decrease by 10, to give the effect of the text scrolling upwards.

    Thanks for the reply.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width