GoTo in VBA

后端 未结 5 2101
情书的邮戳
情书的邮戳 2021-02-16 00:10

From the VBA help file:

GoTo Statement

Branches unconditionally to a specified line within a procedure.

Syntax<

5条回答
  •  甜味超标
    2021-02-16 00:41

    One very useful purpose for old fashion line numbers is for error handling. Many folks utilize a standard error handler of the Sort:

    proc name (args) on error goto handler code . . exit proc

    handler: debug.print err.number & "(" & err.description & ") in Module: " & ModuleName & "- Proc:" & ProcName at & now

    resume next
    Exit Proc

    Which can be made somewhat more useful In the code Is line numbered, as the ErrLine Property will return the line number of the offending executable line.

    debug.print err.number & "(" & err.description & ") - on Line " & errLine & " in Module: " & ModuleName & "- Proc:" & ProcName at & now

提交回复
热议问题