在edit的onkeypress事件中添加程序就行
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var p:integer; tp:TPoint;
begin
if key in ['0'..'9','+','-','.'] then
begin
if key in ['+','-'] then
begin
p:=pos('+',Edit1.Text)+pos('-',Edit1.Text);
if p>0 then key:=#0
else
begin
GetCaretPos(tp);
if tp.x>1 then key:=#0;
end;
end
else
if key='.' then
begin
p:=pos('.',Edit1.Text);
if p>0 then key:=#0;
end;
end
else if key>#31 then key:=#0;
end;