delphi散点知识

来源:互联网 发布:手机淘宝淘抢购 编辑:程序博客网 时间:2024/05/16 07:42

1、如果在TADOTable表post之前取消提交操作

procedure Tform2.ADOTable1BeforePost(DataSet: TDataSet);
begin
   ADOTable1.Cancel;//如果只用这一句,要成功post
   abort;///如果只用这一句,操作会一直停留在这一行,不能换行
end;


2、控制只能输入2位小数的金额

var DotPos,len,fsPos:Integer;
begin
  result:=key;
  if not (key in ['-','0'..'9','.',#13,#8,#27]) then  result:=#0
  else
  begin
    DotPos:=pos('.',je);
    fsPos:=pos('-',je);
    Len:=length(je);
    if key in ['.','-'] then  ///输入小数点的情况
      begin
        if ((key='.') and (DotPos>0)) or ((fsPos>0) and (key='-')) then  //不能多于两个小数点 或负号
          begin
            result:=#0;
            exit;
          end;
        if ((Len<=0) and (key='.')) or ((key='-') and (selStart<>0)) then //开始不能输入小数点,负号只能在开始输
          begin
            result:=#0;
            exit;
          end;
        if (key='.') and (selStart<Len-2) then   ///没有小数点是输入小数点的情况,
        begin
           result:=#0;
            exit;
        end;
      end; 
    if key in ['0'..'9'] then  //输入数字的情况
       if (DotPos>0) and(DotPos<=Len-2) and (selStart>=DotPos) then  result:=#0;
    if key=#13 then result:=#13;
    if key=#27 then result:=#27;
  end;
end;


3、delphi程序里出现cannot create拒绝访问的错误时,这个用户对此盘没有写的权限导致。解决方法:在属性里对everyone的写权限放开