rightstr 和leftstr返回字符都是widestring 和ansistring
我用
var 
actionid :string;
newstring:string;
然后actionid 是从数据库取得的字符串,
newstring:= rightstr(string,6,strlen(string)-5);都有报错。类型不对
请问能怎么转换呢,
谢谢 !

解决方案 »

  1.   

    RightStr functionReturns the substring of a specified length that appears at the end of a string.UnitStrUtilsCategorystring handling routinesDelphi syntax:function RightStr(const AText: AnsiString; const ACount: Integer): AnsiString; overload;
    function RightStr(const AText: WideString; const ACount: Integer): WideString; overload;C++ syntax:extern PACKAGE AnsiString __fastcall RightStr(const AnsiString AText, int ACount);
    extern PACKAGE WideString __fastcall RightStr(const WideString AText, int ACount);DescriptionRightStr returns the trailing characters of AText up to a length of ACount characters. Thus, for example, if AText is the string "Programmer" and ACount is 7, RightStr returns the string "grammer".Note: If AText is an AnsiString and the current locale uses multi-byte characters, RightStr may return more than ACount bytes. To return a specific number of bytes, use RightBStr.
    --------------------------------只有2个参数吧 
    newstring:= rightstr(string,6,strlen(string)-5);
    用了3个参数
    试试
    newstring:= rightstr(string,strlen(string)-5);
    除掉前五个字符后形成的字符串
      

  2.   

    不会有错!
    都是string就可以啊!
      

  3.   


    procedure TForm1.Button1Click(Sender: TObject);
    var
    actionid :string;
    newstring:string;
    begin
    actionid:= 'aaaaaawwwwww';
    newstring:= rightstr(actionid,length(actionid)-5);
    Edit1.Text:= newstring;
    end;