Aar*_*ron 6 delphi uncaught-exception try-except
我有一个模拟骰子卷的程序,并将它们与图表中的值(字符串列表集)进行比较.我目前从TEdit获得价值.如果该框为空,则会引发应该由我的Try/Except语句捕获的EConvertError,但事实并非如此.想法和建议?代码如下,Delphi 7.
try
//Shooting
if ShootingRadio.Checked then
BS := StrToInt(Edit1.Text);
Randomize;
Roll := RandomRange(1,7);
Label3.Caption := IntToStr(Roll);
if (Roll < StrToInt(ShootingHitChart[BS-1])) then
begin
Label3.Caption := (IntToStr(Roll)+' Miss');
RichView1.AddTextNL((IntToStr(Roll)+' Miss'),7,0,1);
RichView1.Reformat;
end
else
begin
Label3.Caption := (IntToStr(Roll)+' Hit');
RichView1.AddTextNL((IntToStr(Roll)+' Hit'),6,0,1);
RichView1.Reformat;
end;
except
MessageBox(0,'No number entered.','Error',mb_OK);
end;
Run Code Online (Sandbox Code Playgroud)
Gol*_*rol 10
在调试器选项中选中"Stop on Delphi exceptions".该异常实际上已被捕获,但IDE会在您获得它时停止.当您继续运行时,您将看不到异常,而是您的消息.在IDE之外它运行良好.
您可以取消选中此选项(我通常这样做).当您需要调试一些顽固的问题时,您可以随时重新检查它.
归档时间: |
|
查看次数: |
3113 次 |
最近记录: |