try .. except语法如何写?

bluespy 2003-11-10 05:36:18
我现在想
case strtoint(s1) of
211: showmessage('heelo');
220: showmessage('what');
end;
但s1有可能是字母而不是数字, 所以在转的时候会出错, 如何实现是字母的就不管它转下一个? 也就是说try .. except语法如何写?
...全文
70 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
manfeng 2003-11-11
  • 打赏
  • 举报
回复
try
case strtoint(s1) of
211: showmessage('heelo');
220: showmessage('what');
end;
except
end;
coolfilm 2003-11-11
  • 打赏
  • 举报
回复
try
case strtointdef(s1, 0) of
211: showmessage('heelo');
220: showmessage('what');
0: ShowMessage('輸入非數字串');
end;
except
showmessage(程序出错)
end;

fengjn 2003-11-10
  • 打赏
  • 举报
回复
case strtointdef(s1, -1) of
211: showmessage('heelo');
220: showmessage('what');
-1:showmessage('number please!');

end;
bluespy 2003-11-10
  • 打赏
  • 举报
回复
except
showmessage(程序出错) //这里写什么让程序不管它继续循环???
end;
aiirii 2003-11-10
  • 打赏
  • 举报
回复
case strtointdef(s1, 0) of
211: showmessage('heelo');
220: showmessage('what');


0: ShowMessage('輸入非數字串');
end;
saien 2003-11-10
  • 打赏
  • 举报
回复
try
case strtoint(s1) of
211: showmessage('heelo');
220: showmessage('what');
end;
except
showmessage(程序出错)
end;

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧