在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
procedure TfrmGoods_InfoAdd.edt_PriceKeyPress(Sender: TObject; var Key: Char);
var DotPos,Len:integer; begin DotPos:=pos('.',(Sender as TEdit).Text); Len:=length((Sender as TEdit).Text); if key in ['0'..'9',#8,'.','+','-'] then begin if (key in ['+','-']) then begin //只能在光标处于第一的位置,才能输入'+'或者'-' if ((Sender as TEdit).SelStart>0) then begin key:=#0; exit; end; //'+','-'互斥 if (pos('+',(Sender as TEdit).Text)>0) or (pos('-',(Sender as TEdit).Text)>0) then begin key:=#0; exit; end; end; if key in ['.'] then begin //只能输入一个'.' if (DotPos>0) then begin key:=#0; exit; end; //只能在'+','-'后面输入'.' if (pos('+',(Sender as TEdit).Text)>0) or (pos('-',(Sender as TEdit).Text)>0) then if ((Sender as TEdit).SelStart<=0) then begin key:=#0; exit; end; //小数点必须在最后两位 if (DotPos<=0) and ((Sender as TEdit).SelStart<Len-2) then begin key:=#0; exit; end; end; if key in ['0'..'9'] then //小数点后面最多两位 if (DotPos>0) and (DotPos<=Len-2) and ((Sender as TEdit).SelStart>=DotPos) then key:=#0 ; end else key:=#0; end; |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论