dimanche 20 novembre 2016

What's wrong with this if statement?

If this receives "ffff", it immediately resolves to true and displays the message box. The way I'm reading this is "if the text, starting at index (which initializes at zero earlier in the code) and going for a distance of 1 (meaning it only evaluates this single letter) is not either A-Z or a-z, then show this message box. Otherwise, exit this if-statement"

Why is that not what's actually happening?

If (txtPartNum.Text.Substring(index, 1) IsNot "[A-Z]" OrElse txtPartNum.Text.Substring(index, 1) IsNot "[a-z]") Then
                MessageBox.Show("Error: Part number must contain two numbers followed by two letters. first")
                blnValid = False
            End If

Aucun commentaire:

Enregistrer un commentaire