I have a function that is not working so fine.
I'd like to run all of over my text and look for a determine word in determine color and change it to another color.
I did a function, but it doesn't work the way that it should be.
Maybe a hand can help me to reach my goal.
This is my code:
procedure ChangeWordColor(RE: TRichEdit; TheWord: String; Color: TColor; Style: TFontStyles);
i, CharPos, noChars: Integer;
CharPos := 0;
noChars := 0;
for i := 0 to Pred(RE.Lines.Count) do
noChars := noChars + Length(RE.Lines[i]);
CharPos := RE.FindText(TheWord, CharPos, noChars, [stWholeWord]);
RE.SelStart := CharPos;
RE.SelLength := Length(TheWord);
if RE.SelAttributes.Color = clRed then
RE.SelAttributes.Color := color;
RE.SelAttributes.Style := Style;