{使Edit控件中只能输入数字和1个小数点 } // 调用 放在Edit的KeyPress事件下 setOnePoint(Key,Edit1); procedureSetEditOnePoint(varKey:Char;CTRL:Tedit); varp:integer;tp:TPoint; begin ifkeyin['0'..'9','+','-','.']then begin ifkeyin['+','-']then begin p:=pos('+',CTRL.Text)+pos('-',CTRL.Text); ifp>0then key:=#0 else begin GetCaretPos(tp); iftp.x>1thenkey:=#0; end; end elseifkey='.'Then begin p:=pos('.',CTRL.Text); ifp>0thenkey:=#0; end; end elseifkey>#31thenkey:=#0; end;