I have some code in a form which attempts to connect to a database i.e.
Catch ex As Exception
MessageBox.Show("Exception opening database: " + ex.Message)
' Close the application
Dim mystring As String = "Hello World"
If the database can't be connected to then the exception is captured as expected. However, the line Application.Exit that I have added does not immediately close the application because, for example, the line with mystring is still called.
My question is, how can I catch the exception and end the application without other code being called?