怎樣保証用戶在tedit中輸入的是數字字符而不是其它字符﹖ 在ONKEYPRESS事件下写代码if Key not in ['0'..'9'] then Key :=#0; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if (key not in [0..9]) then 在KeyPress里面输入如下代码://#8是退格符if not (Key in [#8, '0'..'9']) then begin //不是合法字符 //吃掉这个字符 Key := #0;end; onkeypress if (key >='0')and(key <= '9' )or (key=chr(8))or(key=chr(46)) then exit else key := chr(0); 在KeyPress里面输入如下代码:if (key>#47 or key<#58) or (key=#8) thenbegin key:=#0;end; 在ONKEYPRESS事件下写代码 if ((key>#57) or (key<#48)) and (key<>#8) then begin key:=#0; end; 在ONKEYPRESS事件下写代码 if ((key>#57) or (key<#48)) and (key<>#8) then begin key:=#0; end;绝对好用!! //下面是我作的项目里面的一段程序,也是对输入到TEdit的字符进行限制的//在KeyPress事件中加入一条判断语句就可以了procedure TdlgNewStockDetail.edtGiveupUnitKeyPress( Sender: TObject; var Key: Char);begin inherited;//这行你可以不用. if ( Ord( Key) >= 32) and ( ( Key < '0') or ( Key > '9')) then Key := #0;end; 干吗那么麻烦, 用maskedit不就完了? 把dbgrid中的数据导出到excel中,怎样使数据和dbgrid中的一样自动保留2位小数 DCOM并发访问远程数据 DBGrid里显示的数据是MEMO? 简单问题 iis5+d7+iw7,发布不成功的问题 关于菜单合并,以及如何关闭子窗体。 请交高手:端口问题 如何在DELPHI里面实现简单的SQL查询 循环问题出在哪里呢。请教高手 小调查,如果你做数据库项目,请近来 高手请帮帮我把 有没有在用友做过支持或实施的,薪水怎么样?
//#8是退格符
if not (Key in [#8, '0'..'9']) then
begin
//不是合法字符
//吃掉这个字符
Key := #0;
end;
exit
else
key := chr(0);
if (key>#47 or key<#58) or (key=#8) then
begin
key:=#0;
end;
if ((key>#57) or (key<#48)) and (key<>#8) then
begin
key:=#0;
end;
if ((key>#57) or (key<#48)) and (key<>#8) then
begin
key:=#0;
end;
绝对好用!!
//在KeyPress事件中加入一条判断语句就可以了
procedure TdlgNewStockDetail.edtGiveupUnitKeyPress( Sender: TObject;
var Key: Char);
begin
inherited;//这行你可以不用.
if ( Ord( Key) >= 32) and ( ( Key < '0') or ( Key > '9')) then
Key := #0;
end;