procedure TForm1.Edit1Change(Sender: TObject);
var
i,Count: Integer;
begin
for i := 1 to Length(Edit1.Text) do
begin
if ByteType(Edit1.Text,i) <> mbSingleByte then
Count := Count + 1;
end;
showMessage('中文字有: '+IntToStr(Count div 2)+' 个');
end;
var s:string;
i,e,c:integer;
begin
s:=Edit1.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;