Hi guys, in my system i have two textobxes that are validated for a correct email format and if any of the emails are wrong a messagebox appears and notifies the user. The problem I'm having is that even when the user is notified the user presses 'OK' on the textbox but my system continues to read the other piece of code and further down my code, it saved the emails to the database, therefore it saved the email in the wrong format
Here is my code where it format checks the email:
Code:
Dim FM As Boolean
Dim FM2 As Boolean
Try
FM = Regex.IsMatch(txtEmail.Text, "\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase)
Catch ex As ArgumentException 'Syntax error in the regular expression
End Try
If Not FM Then
MsgBox("Please Enter An Email Address In The Correct Format")
Else
End If
Try
FM2 = Regex.IsMatch(txtEmail2.Text, "\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase)
Catch ex As ArgumentException 'Syntax error in the regular expression
End Try
If Not FM2 Then
MsgBox("Please Enter An Email Address In The Correct Format")
Else
End If
Does anyone know how i can sort of "pause" my program and then allow the user to change the email before my code carries on.
(the user presses a button which saved the emails)
Thanks