[RESOLVED] rich text box change font color
I have a sub that reads in and changes the selcolor of a rich text box.
The code executes fine and if i run the code and then write in the rich text box the text is the color set by the selcolor but if i click on a button i have set up that simply enters some text into the rich text box the text color stays black (its original color)
what do i need to do to get the text to change to the set color when it is entered like it does when its written in.
Re: rich text box change font color
By using .SelColor u are setting color at a current char (you get that from .SelStart). If you continue to enter text the color should stay the same (until the next .SelColor statement). If you want to change the color at the end of the RTB, before continuing entering the text, you should first set the position:
VB Code:
RichTextBox1.SelStart = Len (RichTextBox1.Text)
'and then set the color...
RichTextBox1.SelColor = vbBlue 'or something...
Re: rich text box change font color
Actually, this can be also used by most RichTextBox's .Sel statements (.SelFontName, .SelFontSize, .SelBold, .SelItalic, .SelUnderline...) ;)
Re: rich text box change font color
Cheers gavio,
i will use the .selstart and see how i get on. thanks again