本文整理自网络,侵删。
1. 实时显示输入汉字与英文字母数目:procedure TForm1.Memo1Change(Sender: TObject);var s: string; i,sum,e,c,t: Integer;begin s := Memo1.Text; e := 0; c := 0; sum := Length(s); for i := 0 to sum do begin if (Ord(s[i]) >= 33) and (Ord(s[i]) <= 126) then begin Inc(e); end; if Ord(s[i]) >= 127 then begin Inc(c); end; end; Label1.Caption := '字母数: ' + IntToStr(e)+ ' 汉字数: ' + IntToStr(c div 2);end;2. 限制memo中输入字符数目:设置MaxLength属性为你想要的数字。
相关阅读 >>
Delphi xe5 android获取手机联系人,并用listview显示
Delphi firedac sqlite不能插入"&"符号
Delphi webbrowser载入自定义html内容并显示
更多相关阅读请进入《Delphi》频道 >>