有什么办法和函数能达到以下功能:
就是当在EDIT里输入一个中文字时返回字符长度为1,当输入一个英文时也返回长度1;
就是说不管输入的是英文还是中文只要是一个字都算长度为1。
总的来说就是返回有多少个字而不是字节长!
                        谢谢

解决方案 »

  1.   

    showmessage(inttostr(Length(WideString('123郑'))));
      

  2.   

    试试我的程序!!!!!!!!
    procedure TForm1.Button1Click(Sender: TObject);
    var
     test:string;
     i,num:integer;
    begin
        test:='1深1刻酱豆腐234';
        num:=0;
         showmessage(inttostr(length(test)));
        for i:=1 to length(test) do
        begin
            if  charlength(test,i) =2 then
               inc(num);
        end;
        num:=length(test)-round(num/2);
        showmessage(inttostr(num));
    end;
    有问题发消息给我1!!
      

  3.   

    你就判断你输入的是字符还是字母,如果是字母,长度就是原来的,如果是字符,长度就除2.
    有问题请发信息到我的E-mail:[email protected]
    来信请把问题的网址粘贴上。