38. Try Catch

In this tutorial, we cover how to deal with unhandled exceptions using try catch. If your application has ever stopped working because of an unhandled exception, you will understand how frustrating it is. Using try catch, you can set a failsafe for errors and then choose a way to deal with them.

Code

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Process.Start(TextBox1.Text)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

End Class