1
Answer

Error handling

Kevin Davis

Kevin Davis

13y
1.4k
1
Hello everyone,

I have a several subroutines inside another sub that runs some error checking, and if none of those errors occur, i would like the containing sub to execute, but if any of the other errors occur, I want the containing sub to exit. I'm having a problem using the "exit sub" statement. It still allows a popup message to happen when I don't want it to. Example:
Try
If txtAddress.text = "" then
MsgBox("Please enter a valid address.")
End If


If txtCity.Text = "" Then
MsgBox("Please enter a city.")
End if

If txtState.Text = "" Then
MsgBox("Please enter a state.")
End If

Catch ex as Exception
msgbox(ex.Message)
End try
If none of these occur then I would like the routine to: Msgbox("Your location has been saved.")
Otherwise, I don't want the "Your location has been saved" msgbox to appear. In other words, if any of the three errors occur, exit the sub and show no popup, otherwise show saved popup.

Thanks in advance.
Answers (1)