作者youngswallow (swallow)
看板Visual_Basic
标题[VBA ]错误跳过(on error resume next);那错误不跳过重来执行一遍?
时间Sat Jul 8 22:15:22 2006
错误跳过的指令是:on error resume next;
那错误不跳过重来执行一遍要如何写
假设错误则跳过
sub test()
for i = 1 to 700
on error resume next
cells(i,1)=time
application.ontime now + timevalue("00:00:01"),"thisworkbook.exeself"
next
end sub
假设i=400时发生问题
则跳过;执行i=401
如果我不想跳过的话要如何写
我想要发生错误时再重来执行一遍;就是我一定要执行成功
我的想法是
sub test()
for i = 1 to 700
if error then i=400 '我乱写 ,因为我不会
cells(i,1)=time
application.ontime now + timevalue("00:00:01"),"thisworkbook.exeself"
endif
next
end sub
以上例子只是我举例而已
请各位高手不吝赐教
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.131.65.134
1F:→ youngswallow:如果我写 on error goto 0 则i会从1或者400重新执行? 07/08 22:31
2F:推 colawei:公司规定不能用goto所以我会写if err.number<>0 then... 07/08 22:53
3F:推 LPH66:goto 0是取消on error... 07/08 22:55
5F:推 youngswallow:我会了 谢谢各位帮忙 07/12 14:08