Delphi中判断字母与汉字
生活随笔
收集整理的這篇文章主要介紹了
Delphi中判断字母与汉字
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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;
總結
以上是生活随笔為你收集整理的Delphi中判断字母与汉字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 飞鸽传书2014怎么用?
- 下一篇: delphi查找对话框