为什么try..except..在调试过程中报错,而直接运行项目.exe中却运行正常?
procedure tinput.edit7exit(sender: tobject);
begin
try
strtofloat(edit7.text);
except
begin
application.messagebox(输入的数据不合法,提示,mb_iconinformation+mb_ok);
edit7.setfocus;
end;
end;
end;
在编程环境中运行时,输入非法数据总是出错,而直接运行项目.exe文件后程序执行正常?这是为什么??
推荐阅读
本来就是错误处理啊,在调试环境下当然会显示错误了,而编译成exe出现错误就跳到except中运行不会出现提示
tools->debugger options->language exceptions->stop on delphi exceptions
这个属性设置可以让你的程序在调试的时候是否跳到except中
procedure tinput.edit7exit(sender: tobject);
begin
try
strtofloat(edit7.text);
except
application.messagebox(输入的数据不合法,提示,mb_iconinformation+mb_ok);
edit7.setfocus;
end;
end;
不可能.如果输入的数据里包括字母,一定会提示出错.


讨论区