Skip to content

RESUME


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

语法

Resume

说明

Resume 用于传统 QB 错误处理机制中的错误处理程序(由 On Error 调用),将执行返回到导致错误的行。通常在妥善处理错误后使用,以便用更正的数据重新尝试之前出错的操作。

ResumeErr 值重置为 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 time

end GeSHi

方言差异

  • RESUME 在 -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 是开源项目,与微软公司无隶属关系