Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'To Trap an error use the Try - Catch
Try
'Put your code here that you want to try
'This will stop your application from shutting down
'if a problem comes up.
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
'With a small amount of work, you can use more defined types of catch errors and apply different messages that will make more sense to you instead of the standard exception has occurred. You can have as many catch lines as you want for each kind of error.