>>61
begin
    cnt:=0;
    spos:=0;

    str:=RichEdit1.Text;
    PStr:=PChar(str);
    len:=Length(sword);

    repeat
        p:=AnsiPos(sword, PStr+spos);

        if (p>0) then
        begin
            Inc(cnt);
            Inc(spos, p);

            with RichEdit1 do
            begin
                SelStart:=spos-1;
                SelLength:=len;
                SelAttributes.Color:=clRed;
            end;
            Inc(spos, len);

        end;

    until p=0;
    ShowMessage(IntToStr(cnt));
end;
//ここまで
よろしくお願いします。