procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If Key=8 Then //允许退格键
Key:=8
Else If Key=46 Then //如果输入小数点(ascii=46)
begin
If usdPoint=False Then //如果以前未输入过小数点
begin
Key:=46;
usdPoint:=True; //将小数点输入标志改为true
end
Else
Key:=0; //如果以前输入过则不实行任何操作
end
Else if (Key<48) Or (Key>57) Then //输入非数字则不实行任何操作
Key:=0;
end;
我不知道错在哪里?我想实现:在edit中按下键时判断是否为数字或小数点及退格键,如果不是就不显示。
Shift: TShiftState);
begin
If Key=8 Then //允许退格键
Key:=8
Else If Key=46 Then //如果输入小数点(ascii=46)
begin
If usdPoint=False Then //如果以前未输入过小数点
begin
Key:=46;
usdPoint:=True; //将小数点输入标志改为true
end
Else
Key:=0; //如果以前输入过则不实行任何操作
end
Else if (Key<48) Or (Key>57) Then //输入非数字则不实行任何操作
Key:=0;
end;
我不知道错在哪里?我想实现:在edit中按下键时判断是否为数字或小数点及退格键,如果不是就不显示。
解决方案 »
- 请问在非阻塞状态下ServerSocket可同时连接多少个客户端
- 我就这么多分了,希望各位高手帮帮忙,帮小弟解决这个问题,见人有分!!!(关于timer组件监视数据库的问题)
- 用delphi7开发bs三层数据库
- 请教一个datetimepick问题!
- 搜索引擎中的汉字变成 %BD%CC%B3%CC+%CA%E9 请问怎么 互相转化的呢?
- http://Netbroad.NET/vod/user/reg.jsp?upname=silyangel
- 怪病?????????????????
- 使用Delphi进行iOS开发网络技术研讨会 2013年8月30日(周五) 10:00 –11:00
- DELPHI怎样实现登陆局域网的某台电脑,然后将指定程序拷贝过去
- 请教在DELPHI中能否像C语言那样定义和使用静态变量?
- 买了张倒版盘,里面有个data1.sys文件考不出来,提示:文件可能正在被使用!跪求高手指教!
- 如何向ADOquery控件中添加动态sql参数?
begin
If Key=#8 Then //允许退格键
Key:=#8
Else If Key=#46 Then //如果输入小数点(ascii=46)
begin
If usdPoint=False Then //如果以前未输入过小数点
begin
Key:=#46;
usdPoint:=True; //将小数点输入标志改为true
end
Else
Key:=#0; //如果以前输入过则不实行任何操作
end
Else if (Key<#48) Or (Key>#57) Then //输入非数字则不实行任何操作
Key:=#0;
end;你试一下。
begin
// inherited; if key in ['0'..'9', '.'] then
begin
if (key = '.') and (pos('.', TEdit(Sender).Text) > 0) then key:=#0;
end
else if key > #31 then key := #0;
end;
var
inputpoint :boolean;
初始化为true;begin
if (key in ['.']) then inputpoint = false;
if not (key in ['0'..'9']) then begin
if ((key in ['.']) and inputpoint = false) then key := #0 ;
key := #0;
end;
end;
begin
if key not in ['0'..'9', '.',#8] then
key:=#0;
end;