我在Memo字段(Access)存储了rtf格式的文件,用RxDBRichText控件访问。
现在我想搜索哪些记录的Memo字段中存在某个指定字符串,如何实现?

解决方案 »

  1.   

    function MemoMatch(Field: TField;
          memobuffer: PChar; val1: PChar;
          matchType: TLocateMatchType;
          CaseSens: Boolean): Boolean;
      var matchPtr: PChar;
        numread   : Integer;
        TmpStr:String;
      begin
        Result := False;
        try
          TmpStr:=DataSet.FieldByName(Field.FieldName).AsString;
          StrPCopy(memobuffer,TmpStr);
          if not caseSens then StrUpper(memobuffer);      if matchType = mtExactMatch then
          begin
            if StrLen(val1) <> numread then Result := False
            else
            begin
              matchPtr := StrPos(memobuffer, val1);
              if matchPtr <> nil then
                Result := (matchPtr = memobuffer);
            end
          end else if matchType = mtPartialMatchStart then
          begin
            matchPtr := StrPos(memobuffer, val1);
            if matchPtr <> nil then
              Result := (matchPtr = memobuffer);
          end
          else if matchType = mtPartialMatchAny then
          begin
            matchPtr := StrPos(memobuffer, val1);
            Result := (matchPtr <> nil);
          end
          else Result := False;
        finally    end;
      end;
      

  2.   

    此函数来自Component : TwwLocateDialog(IP4000)
    Copyright (c) 1995-2001 by Woll2Woll Software