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;
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;