| 发表于:2007-04-20 19:49:072楼 得分:25 |
把写入文件的过程放在一个函数里,再利用错误捕捉语句实现判断是否执行成功. private function savefile(byval filename as string) as boolean on error goto errhandle savefile = false open filename for output lock read write as #1 '写文件的代码 savefile=true close #1 exit function errhandle: close #1 end function 然后调用时,就自己用个循环去调用.如果这个过程返回f,当然就是出错了,你就延时后再调用(这些自己处理吧) dim tmpi as long '控制超时的变量 tmpi=0 do if savefile( "d:\xxxxxx.txt ")=true then exit do '完成了,就退出 end if sleep 2000 '延时两秒 tmpi=tmpi+1 if tmpi=5 then msgbox "超时! " '十秒后超时.自己处理. exit do end if loop 应该是可以运行的,懒得在ide里试了,呵呵 | | |
|