Dim errTimes As Integer
Dim beginTimes As Integer
On Error GoTo err
errTimes = 1
beginTimes = 0beginning:
beginTimes = beginTimes + 1
Open Text2.Text For Output As #1
Print #1, Text1.Texterr:
If errTimes = 3 Then
MsgBox "errTimes = 3 beginTimes = " + CStr(beginTimes)
Close #1
Else
MsgBox "error"
errTimes = errTimes + 1
Close #1
MsgBox "begin again"
GoTo beginning
End If如果text2.text所表示的路径不存在,程序运行第一次可以捕捉到错误,并且跳转到err所指示的地方,可是第二次就直接弹出错误窗口了。这是怎么回事?难道on error goto 不能够捕捉相同的错误吗?
Dim beginTimes As Integer
On Error GoTo err
errTimes = 1
beginTimes = 0beginning:
beginTimes = beginTimes + 1
Open Text2.Text For Output As #1
Print #1, Text1.Texterr:
If errTimes = 3 Then
MsgBox "errTimes = 3 beginTimes = " + CStr(beginTimes)
Close #1
Else
MsgBox "error"
errTimes = errTimes + 1
Close #1
MsgBox "begin again"
GoTo beginning
End If如果text2.text所表示的路径不存在,程序运行第一次可以捕捉到错误,并且跳转到err所指示的地方,可是第二次就直接弹出错误窗口了。这是怎么回事?难道on error goto 不能够捕捉相同的错误吗?
解决方案 »
- 如何取DataGrid控件中的数据到ORACLE中?
- image 控件,移到图片控件是时,光标就变成手指
- 在vsflexgrid中,如何区分用鼠标点击的是左上角白色表格部分,还是剩下的深灰色背景部分呢?
- 为什么更新无效
- 一个WebBrowser中设置高亮遇到的问题,望解答,
- 小弟在做个应用程序的主界面.但是不知道导航树的那个控件如何作.好像是VIEWTREE.或者是别的.
- 在VB的FOR语句中使用什么语句退出本次循环 不使用EXIT FOR
- 一个SENDMESSAGE问题
- 哪位高手用VB二次开发过MAPINFO?
- VB中使用API函数的疑问???????还请各位大虾们帮忙
- 在线等待:怎么用VB显示一条特定的记录?
- 求助在activereport裏分組打印的問題
所以,对于你的程序,把 GoTo beginning 哪一句修改为 Resume Beginning 就可以捕获到三次错误了。
所以,对于你的程序,应该把 GoTo beginning 修改为 Resume Beginning,而且在err:前加上exit sub或者goto xxx,否则程序在没发生错误情况下执行到resume语句时会出错。