摘要: procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);begin case Key of '0'..'9': ; //对数字键响应 #8,#9,#37,#39,#46,#35,#36:; //对退格键、Tab键、左右箭头响应 #1,#3,#22,#24:;//对Ctrl C、V、A、X响应原帖http://www.delphibbs.com/delphibbs/dispq.asp?lid=1410308 对自己程序的修改: if not(key in ['0'..'9 阅读全文
posted @ 2011-04-01 23:03 吴越 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 原来的代码无法限制只输入一个小数点begin case Key of '0'..'9', #8, #13,#45, #27, '.' : ; //#8退格键,#13回车键 //可输入0-9,退格,回车,点以及负号 else begin MessageBox(0, '请输入数值!', '输入错误', MB_OK+MB_ICONERROR); Key := #0; end; end; end;限制只输入一个小数点:在keypress事件加入如下代码即可 if not (key in ['0'..' 阅读全文
posted @ 2011-04-01 22:32 吴越 阅读(562) 评论(0) 推荐(0) 编辑