Ho un attimo di defaillance mentale, per cui mi sfugge un attimo il senso del blocco Finally in Try... Catch
Esso è definito come un blocco in cui il codice viene eseguito COMUNQUE, ma la mia domanda è: ma tutto il codice che SEGUE un Try... Catch non viene eseguito comunque ?
Faccio un esempio pratico per non andare OT:
codice:
Private Sub Pippo()
Dim Str1 as String = "Pippo"
Dim Str2 as string = nothing
Try
Str1 = .... codice che potrebbe provocare errore
Label1.Text = Str1
Catch ex as Exception
Debug.Print ex.ToString
Finally
Str1 = Nothing
Str2 = "Paperino"
End Try
End Sub
codice:
Private Sub Pippo()
Dim Str1 as String = "Pippo"
Dim Str2 as string = nothing
Try
Str1 = .... codice che potrebbe provocare errore
Label1.Text = Str1
Catch ex as Exception
Debug.Print ex.ToString
End Try
Str1 = Nothing
Str2 = "Paperino"
End Sub
una volta eseguite, le due sub danno lo stesso risultato per Str1 e Str2... ma allora quale è la funzione pratica di Finally??