首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

请教怎么限制用户在edit文本框内只能输入数字或小数

2012-02-24 
请问如何限制用户在edit文本框内只能输入数字或小数?请问如何限制用户在edit文本框内只能输入数字或小数?

请问如何限制用户在edit文本框内只能输入数字或小数?
请问如何限制用户在edit文本框内只能输入数字或小数?
或者如何判断出用户在edit文本框中输入的不是数字或小数?
(例如只能输入15,12.36等等)

谢谢。

[解决办法]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Not(Key in [ '0 '.. '9 ', '. ']) then Key := #0;
end;
[解决办法]
procedure TForm32.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in [ '0 '.. '9 ', '. ' ,#8,#13]) then
key := #0 ;
if (key = #13) and (trim(edit3.Text) <> ' ') then
begin
if (form32.ComboBox2.ItemIndex = 5) or (form32.ComboBox2.ItemIndex = 6) then
begin
Form32.Edit5.SetFocus ;
Form32.Edit5.SelectAll ;
end
else
begin
Form32.Edit4.SetFocus ;
Form32.Edit4.SelectAll ;
end ;
end ;
end;

热点排行