-
April 30th, 2009, 02:21 PM
#1
several colors in an RTB (rich text box)
Hello:
I need to show something like "EAT EVERY JELLYFISH" in a rich textbox with each word in a different color (say red, green blue)...
I use selstart sellength & selcolor, but only the LAST word has the new color, the other words revert back to the normal back text. Is it possible to have various separated words shown in different colors at the same time?
I will actually have a long list of many sentences and want certain things highlighted in color(s).
I would like a routine to append a green word, red word, or blue word to the present rtb contents such as:
this does not seem to work:
Public Sub rtbAppendText(NuText As String, Color As Long)
Dim oldLen As Long
oldLen = Len(rtbCmdLog.Text)
rtbCmdLog.Text = rtbCmdLog.Text & NuText
rtbCmdLog.SelStart = oldLen
rtbCmdLog.SelLength = Len(rtbCmdLog.Text) - oldLen
rtbCmdLog.SelColor = Color
rtbCmdLog.SelLength = 0
rtbCmdLog.SelStart = 1
End Sub
Last edited by vbcandies; April 30th, 2009 at 02:30 PM.
-
April 30th, 2009, 02:59 PM
#2
Re: several colors in an RTB (rich text box)
I fixed it---just re-sequenced some of my steps. Here it is, also cleaned up a bit
Public Sub rtbAppendText(NuText As String, Color As Long)
Dim oldLen As Long
On Error Resume Next
With rtbCmdLog 'this is the name of the rich tecxt box being used
oldLen = Len(.Text)
.SelStart = oldLen
.SelColor = Color
.SelText = .SelText & NuText
End With
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|