Click to See Complete Forum and Search --> : Coloured RTF
nick99
Nov 23rd, 1999, 09:22 AM
I have a rich text box with three colours, red, green and yellow. How can I extract only the red text from this RTF.....
Thank you.
Any help will be great
mystiq
Nov 23rd, 1999, 09:41 AM
Here's an algorithm:
Function GetRedString(rtf as RichTextBox) As String
dim i as long,ret as string
rtf.sellength = 1
for i = 1 to len(rtf.text)
rtf.selstart = i
if rtf.selcolor = vbRed then ret = ret & rtf.seltext
next i
GetRedString = ret
End Function
I just wrote that off the top of my head, so im not 100% sure it works, give it a whirl. Basically it checks the RGB value of each character in the textbox against the selected color, if they match it adds the character to a string, and returns it.
------------------
-Mystiq
nick99
Nov 23rd, 1999, 11:41 AM
Thank you mystiq.
In the algorithm you provided, the rtf.selcolor only returns the color of the last character in the RTF.
Are there any more methods extracting the red text??
Thankful
nick99
Nov 23rd, 1999, 11:54 AM
i would like to know how to communciate with a com port. when the input to the com port only have the transmit data pins and earth, no rts and cts. can i use comEvent to do it?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.