procedure TForm1.Button1Click(Sender: TObject);
var
character,i,characterenglish,characterchinese:integer;
str:string;
begin
i:=1;
character:=0;
str:=memo1.Lines.Text;
if length(str)>0 then
while not(i>length(str)) do
begin
if (ord(str)=32) then
i:=i+1
else if(ord(str)=13) then
i:=i+2
else
begin
if(ord(str)>=129) and(ord(str)<=254) and (ord(str[i+1])>=64) and (ord(str[i+1])<=254) then
begin
i:=i+2;
character:=character+1;
characterchinese:=characterchinese+1;
end
else
begin
i:=i+1;
character:=character+1;
characterenglish:=characterenglish+1;
end;
end;
end;
label1.caption:='总共字符'+inttostr(character);
label4.Caption:='中文字符'+inttostr(characterchinese);
label6.Caption:='英文字符'inttostr(characterenglish);
end;