Delphi字符统计和汉字统计
该日志由
samool 发表于 2007-10-21 10:31 PM
delphi代码
- procedure TForm1.btn1Click(Sender: TObject);
- var i,e,c:integer;
- s:string;
- begin
- s:=mmo1.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条记录)
发表评论:( 来了就留个脚印吧!你的参与是我最大的动力!)