1:StringOfChar()
stringofchar(' ',20)
2.自己写个函数。

解决方案 »

  1.   

    1、同上
    2、length是确定字符串长度啊!!!
      

  2.   

    to all:
      一个汉字长度应该是2,而一个字母长度是1,这不同于字符个数的概念。
      

  3.   

    字符串的长度用length()就可以了。
    字符的个数必须自己写一个函数进行判断字符的高位字节是否大于160!如果是的话,就是一个汉字,就把两个算一个!
      

  4.   

    统计中英文个数:想在文本控件TMemo中,分别对中、英文的字符数进行统计,我们可以通过把字符转换为数值来进行判断,Ord()函数把字符转换为对应的数值,值33-126为键盘可使用字符,值127以上的为未知字符,即为汉字
    procedure TForm1.Button1Click(Sender: TObject);
    var 
      s:string;
      i,e,c:integer;
    begin
      s:=memo1.text;
      e:=0;c:=0;
      for i:=1 to length(s) do
      begin
        if (ord(s[i])>=33)and(ord(s[i])<=126) then
        begin
          inc(e);
          label1.caption:='英文个数:'+inttostr(e);
        end
        else 
          if (ord(s[i])>=127) then
          begin
          inc(c);
          label2.caption:='中文个数:'+inttostr(c div 2);
          end;
      end;
    end; 
      

  5.   

    统计中英文个数:想在文本控件TMemo中,分别对中、英文的字符数进行统计,我们可以通过把字符转换为数值来进行判断,Ord()函数把字符转换为对应的数值,值33-126为键盘可使用字符,值127以上的为未知字符,即为汉字
    procedure TForm1.Button1Click(Sender: TObject);
    var 
      s:string;
      i,e,c:integer;
    begin
      s:=memo1.text;
      e:=0;c:=0;
      for i:=1 to length(s) do
      begin
        if (ord(s[i])>=33)and(ord(s[i])<=126) then
        begin
          inc(e);
          label1.caption:='英文个数:'+inttostr(e);
        end
        else 
          if (ord(s[i])>=127) then
          begin
          inc(c);
          label2.caption:='中文个数:'+inttostr(c div 2);
          end;
      end;
    end;