U ugvanxk Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-18 #4 http://www.delphibbs.com/keylife/iblog_show.asp?xid=1033
M mapwindow Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-18 #6 你可以随便选一个组件(如edit),然后用代码将其锁定成只能输数字即可呀[] LOOK 选用EDIT组件,代码自已随便写 if (key<=#47) or (key>=58) then begin key:=chr(0); end; [][][]
你可以随便选一个组件(如edit),然后用代码将其锁定成只能输数字即可呀[] LOOK 选用EDIT组件,代码自已随便写 if (key<=#47) or (key>=58) then begin key:=chr(0); end; [][][]
大 大白鲨king Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-18 #7 void __fastcall TForm1::Edit1OnKeyPress(TObject *Sender, char &Key) { AnsiString InputKey = Key; AnsiString ValidKey = AnsiString("0123456789." if (ValidKey.Pos(InputKey) == 0) { Key = 0; } } Unit1.h TForm *Form1; TEdit *Edit1;
void __fastcall TForm1::Edit1OnKeyPress(TObject *Sender, char &Key) { AnsiString InputKey = Key; AnsiString ValidKey = AnsiString("0123456789." if (ValidKey.Pos(InputKey) == 0) { Key = 0; } } Unit1.h TForm *Form1; TEdit *Edit1;
W wzwcn Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-18 #8 以前自己写了一个,想要代码的请给我写信。wzwcn@163.com
K kuangfuhxw Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-18 #10 在keypress 事件中加入以下代码 if not((key>='0') and (key<='9'))or key=#8) then //#8代表Backspace key:=#0
I iamy Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-18 #11 还有科学记数法表示的数字 判断起来可能要复杂一点 用maskedit试试
X xianguo Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-19 #13 procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (key in ['0'..'9', #8]) then key:=#0; end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (key in ['0'..'9', #8]) then key:=#0; end;
A andy_he Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-20 #14 输入控件,用代码来实现它的键盘事件,达到你想要的效果。
笑 笑江横 Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-21 #16 来迟了,我一直用kuangfuhxw和xianguo说的这个方法
H herotjun Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-22 #17 procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin try StrTofloat(Edit1.text); except messagebox(handle,'please input number!','Error',MB_OK); end; end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin try StrTofloat(Edit1.text); except messagebox(handle,'please input number!','Error',MB_OK); end; end;
B babibean Unregistered / Unconfirmed GUEST, unregistred user! 2005-05-24 #18 来自:kuangfuhxw, 时间:2005-5-18 23:17:11, ID:3077762 在keypress 事件中加入以下代码 if not((key>='0') and (key<='9'))or key=#8) then //#8代表Backspace key:=#0 ---------------------- 这个方法只能对整数进行处理,如果搂主所说的数据包含小数的话,可能另外需要控件。
来自:kuangfuhxw, 时间:2005-5-18 23:17:11, ID:3077762 在keypress 事件中加入以下代码 if not((key>='0') and (key<='9'))or key=#8) then //#8代表Backspace key:=#0 ---------------------- 这个方法只能对整数进行处理,如果搂主所说的数据包含小数的话,可能另外需要控件。