Does anyone here know how when someone adds text to richtextbox, you can not keep the original text coloring?
Here is an example of what I mean
So when I click the command once, it colors the beginning text of the rtb to red, then it adds the word yahoo and colors it blue. But when I click it again, it adds the old text and covers the it all red, then it adds the second yahoo and colors it green. But I lost the original color of blue on the first yahoo.Code:Private Sub Command1_Click() Dim x As Integer If (color) Then rtb.SelStart = 0 rtb.SelLength = Len(rtb.Text) rtb.SelColor = vbRed End If MsgBox rtb.SelStart If (color) Then x = Len(rtb.Text) rtb.Text = rtb.Text & " Yahoo " rtb.SelStart = x rtb.SelLength = 7 rtb.SelColor = vbBlue Else x = Len(rtb.Text) rtb.Text = rtb.Text & " Yahoo " rtb.SelStart = x rtb.SelLength = 7 rtb.SelColor = vbGreen End If color = False End Sub Private Sub Form_Load() color = True End Sub
[Edited by billrogers on 05-25-2000 at 09:26 AM]




Reply With Quote