Results 1 to 3 of 3

Thread: Add text to a Rich Text Box

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Adelaide - Australia
    Posts
    150
    I want to add a line of text to a RTB one at a time each one colored differently. I have found many examples of adding a line at a time but this always adds it to the bottom of the RTB and I would like to add it to the top. This saves the user having to scroll down to the bottom of the list.
    Can anyone out there please help me.

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Set the SelStart Property to 0. Then set the SelColor to whatever.

    As you say you know a bit about RTB's, i will assume you know that you cant just concatinate strings if you want to save formating. So one way to get around this is to use the SendKeys Method.

    Good luck!

    Iain, thats with an i by the way!

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Try this:
    Code:
    Private Sub Command1_Click()
        Dim i As Integer
        
        With RichTextBox1
            For i = 1 To 5
                .SelStart = 0
                .SelColor = Choose(i, vbRed, vbBlue, vbGreen, vbCyan, vbMagenta)
                .SelText = "This is line " & i & vbCrLf
            Next
        End With
    End Sub

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