RESUME
- 来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgResume
- 最后更新: 2018-05-14
跳转到错误处理程序后用于恢复执行的错误处理语句
语法
Resume说明
Resume 用于传统 QB 错误处理机制中的错误处理程序(由 On Error 调用),将执行返回到导致错误的行。通常在妥善处理错误后使用,以便用更正的数据重新尝试之前出错的操作。
Resume 将 Err 值重置为 0
示例
start GeSHi
vb
'' Compile with -lang fblite or qb
#lang "fblite"
Dim As Single i, j
On Error Goto ErrHandler
i = 0
j = 1 / i ' this line causes a divide-by-zero error on the first try; execution jumps to ErrHandler label
Print j ' after the value of i is corrected, prints 0.5
End ' end the program so that execution does not fall through to the error handler again
ErrHandler:
i = 2
Resume ' execution jumps back to 'j = 1 / i' line, which does not cause an error this timeend GeSHi
方言差异
- RESUME 在 -lang fb 方言中不受支持。语句可以以其函数形式使用以返回错误代码
start GeSHi
vb
If Open( "text" For Input As #1 ) <> 0 Then
Print "Unable to open file"
End Ifend GeSHi
与 QB 的区别
另请参阅
ErrResume Next- 错误处理
返回 目录