delphi编程问题
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not key in ['0'..'9'] then key:=char(0); end;大家看这段程序有什么问题?编译老是不过,提示Operator not applicable to this operand type,错误光标在in后面
追问:唉,没有错啊,但是这提示也太不靠谱了吧,害我查了半天
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not key in ['0'..'9'] then key:=char(0); end;大家看这段程序有什么问题?编译老是不过,提示Operator not applicable to this operand type,错误光标在in后面
追问:唉,没有错啊,但是这提示也太不靠谱了吧,害我查了半天
答案:少了个括号,加个括号吧,Delphi 的语法没有C的这么灵活
改成
if not (Key in ['0'..'9']) then key:=char(0);