{使该编辑框只能输入数字类型的数据} if (edit3.Text='') and (key='.') then begin key:=#0; exit; end; if (edit3.text='0') and not (key in ['.',#8,#13,#27]) then begin key:=#0; exit; end; if (pos('.',edit3.text)>0) and (key='.') then begin key:=#0; exit; end; if not (key in ['0'..'9','.',#8,#13,#27]) then key:=#0;
方法好多啊,以前只知道一个,现在…………呵呵。学习ing
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (key in ['0'..'9',#8,#13]) then key :=#0 end;
if (edit3.Text='') and (key='.') then begin key:=#0; exit; end; if (edit3.text='0') and not (key in ['.',#8,#13,#27]) then begin key:=#0; exit; end; if (pos('.',edit3.text)>0) and (key='.') then begin key:=#0; exit; end; if not (key in ['0'..'9','.',#8,#13,#27]) then key:=#0;-----------------------------------------------------------------------------DelphiICQ编程站,至力于发展编程技术!http://www.DelphiICQ.com/
if (edit3.Text='') and (key='.') then
begin
key:=#0;
exit;
end;
if (edit3.text='0') and not (key in ['.',#8,#13,#27]) then
begin
key:=#0;
exit;
end;
if (pos('.',edit3.text)>0) and (key='.') then
begin
key:=#0;
exit;
end;
if not (key in ['0'..'9','.',#8,#13,#27]) then
key:=#0;
begin
if not (key in ['0'..'9',#8,#13]) then
key :=#0
end;
if (edit3.Text='') and (key='.') then
begin
key:=#0;
exit;
end;
if (edit3.text='0') and not (key in ['.',#8,#13,#27]) then
begin
key:=#0;
exit;
end;
if (pos('.',edit3.text)>0) and (key='.') then
begin
key:=#0;
exit;
end;
if not (key in ['0'..'9','.',#8,#13,#27]) then
key:=#0;-----------------------------------------------------------------------------DelphiICQ编程站,至力于发展编程技术!http://www.DelphiICQ.com/