unit Unit1; interface uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, StdCtrls; type 
  TForm1 = class(TForm) 
    Edit1: TEdit; 
  Function OnlyInsNum(Sender: TObject; Key: Char; CanInsNeg: Boolean): Char; 
    procedure Edit1KeyPress(Sender: TObject; var Key: Char); 
  private 
    { Private declarations } 
  public 
    { Public declarations } 
  end; var 
  Form1: TForm1; implementation {$R *.dfm} 
Function TForm1.OnlyInsNum(Sender: TObject; Key: Char; CanInsNeg: Boolean): Char; 
begin {*****限制只输入数字,不能输入两个小数点*****} 
  if not (Sender is TEdit) then 
  begin 
    Result := #0; 
    Exit; //不是TEdit直接退出 
  end; 
  if not (Key in ['0'..'9','.', #27{ESC}, #8{退格}, #13{回车}]) then 
  begin 
    if (CanInsNeg) and (Key = '-')then //如果可以输入负数,并且输入的是负数则返回 
      Result := Key 
    else Result := #0; 
  end 
  else if (Key = '.') and (Pos('.', (Sender as TEdit).Text) <> 0) then    //位小数点,且已经存在小数点了 
  begin 
    Result := #0; //返回不能输入 
  end 
  else 
  begin 
    Result := Key; 
  end; 
end; 
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); 
begin 
Key := form1.OnlyInsNum(Sender, Key);//提示Not enough actual parameters 
end; end. 
提示Not enough actual parameters?
请指点下,谢谢

解决方案 »

  1.   

    自定义函数有三个参数,你只写了两个,还差最后一个CanInsNeg: Boolean
      

  2.   

    Key := form1.OnlyInsNum(Sender, Key,true);//
      

  3.   

    OnlyInsNum(Sender: TObject; Key: Char; CanInsNeg: Boolean): Char;
    CanInsNeg没传参
      

  4.   

    Key := form1.OnlyInsNum(Sender, Key,true);
    不改什么,加了个true就不提示出错是怎么回事
      

  5.   

    因为加了true之后,参数就完整了,不缺少了,所以也就不报错了
      

  6.   

    true就是其中的CanInsNeg参数,而报错的原因,就是缺少这个参数