Skip to content

RESUME NEXT


跳转到错误处理程序后用于恢复执行的错误处理语句

语法

Resume Next

说明

Resume Next 用于传统 QB 错误处理机制中的错误处理程序(由 On Error 调用),将执行返回到导致错误的行的下一行。通常用于避免执行同一行并再次引发错误。

Resume NextErr 值重置为 0

示例

start GeSHi

vb
'' Compile with -lang fblite or qb

#lang "fblite"

Dim As Single i, j

On Error Goto ErrHandler

i = 0
j = 5
j = 1 / i ' this line causes a divide-by-zero error; execution jumps to ErrHandler label

Print "ending..."

End ' end the program so that execution does not fall through to the error handler again

ErrHandler:

Resume Next ' execution jumps to 'Print "ending..."' line, but j is now in an undefined state

end GeSHi

方言差异

  • RESUME NEXT 在 -lang fb 方言中不受支持。语句可以以其函数形式使用以返回错误代码

start GeSHi

vb
If Open( "text" For Input As #1 ) <> 0 Then
  Print "Unable to open file"
End If

end GeSHi

与 QB 的区别

  • 必须使用 -ex-exx 选项编译

另请参阅

返回 目录

基于 FreeBASIC 官方文档翻译 如有侵权请联系我们删除
FreeBASIC 是开源项目,与微软公司无隶属关系