I am a bit confused how to handle the errors in a VB .net app I am writing.
This is what I have:
Private Sub Func1()
Try
'stuff that could raise an error
Catch ex As Exception
MsgBox("There is an error" & ex)
End
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Func1()
'a lot of stuff that will also raise an error is Func1 does
End Sub
This code will exit the application if there is an error.
If I remove the "End", it will go on and raise multiple errors in the Sub Button1_click.
So I need to put something in the Func1 that could interrupt execution the Sub Button1_click.
I could put Exit Sub but I have a lot of Subs that use this Func1 so I'd prefer a way to do it from Func1.
If you don't want to continue exection of Button1_Click if Func1 fails then change Func1 to a boolean Function