代码如下:
1
Procedure TForm1.Button1Click(Sender: TObject);
2
var s:string;
3
I,e,c:integer;
4
begin
5
s:=memo1.text; //Memo的内容
6
e:=0;c:=0;
7
for I:=1 to length(s) do
8
begin
9
if (ord(s[I])>=33)and(ord(s[I])<=126) then
10
begin
11
inc(e);
12
label1.caption:='英文字数:'+inttostr(e);
13
end
14
else
15
if (ord(s[I])>=127) then
16
begin
17
inc(c);
18
label2.caption:='中文字数:'+inttostr(c div 2);
19
end;
20
end;
21
end;

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21
