请教: 在TEdit控件中录入用户信息,如何检测录入的内容全部为数字? 多谢!
解决方案 »
- 数据库查询语句
- 【【【【DELPHI里面除了POS就没有别的查找字串的函数吗?????
- 机器名和计算机名有什么不同???
- getpicklist函數怎么用?
- 关于数据库别名的问题:)
- a easy question
- DELPHI在建立类时能不能加入事件?DELPHI的消息机制又是怎样的?
- 怎么理解这一句:Result := GetDriveType(PChar(DriveChar + ':\')) = DRIVE_CDROM
- 怎样去掉程序打开时的登录窗口?
- 关于记录查找locate的用法
- 一个简单问题,ThreadVar与Var有何不同
- 散分!!如何定义socket消息结构?如何通过socket发送记录?
或者用TEdit.OnKeyPress事件里面自己判断
编写一个小函数如下:function isNumber(str:String):Boolean;
begin
result:=true;
try
strtofloat(str);
except
result:=false
end;
end;当指定的字符串是数字时,返回值为真,否则为假。
begin
if Key not in [0..9] then
exit;
end;
StrToFloat(Edit1.Text);
except
ShowMessage('必须输入数字');
Edit1.SetFocus;
end;可以在TEdit的OnKeyPress时间中通过
if not (Key in [#8, '0'..'9',DecimalSeparator]) then
Key:=#0;控制
var
i : integer;
begin
try
i := StrtoInt(Edit1.Text);
except
ShowMessage('Error!');
end;
end;
var i:integer;begin
for i:=1 to length(txt) do
if (txt[i] in ['0'..'9']) then Result :=true
else Result :=false;
end;