-
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.
-
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!
-
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