I have been familiarising myself with the richtextbox so that I can use it in the future. What I've been trying to do is have to text of the box updated by code, but with different colours but I can't seem to get it right.
Whenever I add text to the box, it is like the formatting set for the previous text is lost (while stepping through the code, the previous formatting the lost when the new text is added). Here is the code I am using:
Thanks,Code:Option Explicit Private Const msg = "123" Private Sub Command1_Click() rtb.Text = rtb.Text & msg rtb.SelStart = Len(rtb.Text) - Len(msg) rtb.SelLength = Len(msg) rtb.SelBold = True rtb.SelLength = 0 End Sub Private Sub Command2_Click() rtb.Text = rtb.Text & msg rtb.SelStart = Len(rtb.Text) - Len(msg) rtb.SelLength = Len(msg) rtb.SelBold = False rtb.SelLength = 0 End Sub
Sunny




Reply With Quote