> RichTextBox1.Te xt = RichTextBox1.Te xt & Text1.Text
You don't want to use the above line because that replace all the current
text (colors, bolding, etc.) with the Text (which is not formatted, Text is
just the characters) already in the RichTextBox plus those characters in the
regular TextBox. Anyway, the proper (read... fastest) way is to "insert" the
new text into the location of the text cursor. You do that by assigning
(only) the new text to the SelText property. If you first change the
SelColor property, then the newly inserted text will be that color. However,
you must remember to set the SelColor back to the color it had before you
changed it. Give this code a try instead of what you posted.
Private Sub Command1_Click( )
Dim CurrentColor As Long
With RichTextBox1
CurrentColor = .SelColor
.SelColor = vbRed
.SelText = Text1.Text
.SelColor = CurrentColor
End With
End Sub
Note that this will insert the text in the regular TextBox at the current
text cursor location, wherever that might be. If you want it to always be
added to the end of the current text, then add this line somewhere IN FRONT
OF the .SelColor=vbRed line (but after the With statement).
..SelStart = Len(.Text)
Rick - MVP
"AttiDude" <at************ ***@hotmail.com > wrote in message
news:ds******** *************** *********@4ax.c om...
Ok I've got now:
Private Sub Command1_Click( )
start1 = Len(RichTextBox 1.Text)
RichTextBox1.Te xt = RichTextBox1.Te xt & Text1.Text
With RichTextBox1
.SelStart = start1
.Span vbCr, True, True
.SelColor = 255
.SelLength = 0
End With
End Sub
This way the richtextbox always makes the last added text red. So if I
add a new text the old text turns black again.
Is there a way to keep the previous text the curremt color?
On Sat, 10 Apr 2004 15:13:52 GMT, "mayayana"
<ma************ @mindZZspring.c om> wrote:
Where Start1 is the offset of the first character in the line:
With RTB
.SelStart = Start1
.Span vbCr, True, True '-- selects line up to carriage return..
.SelColor = 255 '-- [long color value - in this case
red.]
.SelLength = 0 '-- de-select line
End With
--