Error Handler - Exit Sub vs. End Sub

前端 未结 2 690
眼角桃花
眼角桃花 2021-01-07 18:20

Why would I want to get out of an Error Handler (after handling) with an Exit Sub instead of just letting it go to the End Sub?

I\'m sure it\'s simple. I just don\'

2条回答
  •  情深已故
    2021-01-07 18:29

    Typically if you have database connections or other objects declared that, whether used safely or created prior to your exception, will need to be cleaned up (disposed of), then returning your error handling code back to the ProcExit entry point will allow you to do your garbage collection in both cases.

    If you drop out of your procedure by falling to Exit Sub, you may risk having a yucky build-up of instantiated objects that are just sitting around in your program's memory.

提交回复
热议问题