Friday, 20 July 2012

try catch block in vb.net

In this tutorial, we cover how to deal with unhandled exceptions (errors in vb.net application) using try catch block. If your application has ever stopped working because of an unhandled exception, you will understand how frustrating it is. Using try catch block, you can set a failsafe for errors and then choose a way to deal with them, and you can make your own errors and display in message box or text box.

Copy and paste below 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

No comments:

Post a Comment