So I have a user sign up form. There are textboxes for entering name, age, username, password, confirm password, security question and answer. Before clicking the Submit button, I want to make sure all the boxes are filled and the password matches.
PasswordMatch returns whether the password matches or not as True or False
This is my code:
Private Sub SaveButton_Click(sender As System.Object, e As System.EventArgs) Handles SaveButton.Click
'check if everything is filled
If Name_TxtBox.Text <> "" And Age_Box.Text <> "" And username_Box.Text.Length > 4 And PasswordMatch = True And Security_Ques.Text.Length > 5 And Answer_Box.Text.Length > 2 Then
'yupp, everything fine. now continue
End If
End Sub
Now, I want to know exactly which condition was False so I can react accordingly.
Is there some way to know this? Like catching an exception or something? I know it has nothing to do with this here but I just thought maybe we can catch which condition is false.
I saw this answer and they recommended to use ElseIf. That could be a way but that would be too lengthy and take more lines of code.
Aucun commentaire:
Enregistrer un commentaire