I see that the Finally
in Try .. Catch
will always execute after any parts of the execution of the try catch block.
Is it any different to just skip the Finally
section and just run it after, outside the try catch block?
Try
'Do something
Catch ex As Exception
'Handle exception
Finally
'Do cleanup
End Try
Try
'Do something
Catch ex As Exception
'Handle exception
End Try
'Do cleanup
Yes, it is different. Finally will always run (barring program crash). If the function exits inside of the try catch block, or another error is thrown in either the try or the catch, the finally will still execute. You won't get that functionality not using the finally statement.