Hello,
I've been asked to validate the content of a text box to make sure it's only alphanumeric.
Now I have 2 question on this from you experts:
1. alphanumeric value needs to start with alpha or it can start with numbers also?
2. I wrote the following code to test my entry but it's somewhere wrong I cannot understand! How can I go through each character to make sure it's alphanumeric?
I've been asked to validate the content of a text box to make sure it's only alphanumeric.
Now I have 2 question on this from you experts:
1. alphanumeric value needs to start with alpha or it can start with numbers also?
2. I wrote the following code to test my entry but it's somewhere wrong I cannot understand! How can I go through each character to make sure it's alphanumeric?
Visual Basic:
For MyLoop As Integer = 0 To PasswordTextBoxX.Text.Length - 1
If PasswordTextBoxX.Text.Substring(MyLoop, 1) <= "a" Or PasswordTextBoxX.Text.Substring(MyLoop, 1) >= "z" And _
PasswordTextBoxX.Text.Substring(MyLoop, 1) <= "A" Or PasswordTextBoxX.Text.Substring(MyLoop, 1) >= "Z" And _
PasswordTextBoxX.Text.Substring(MyLoop, 1) <= "0" Or PasswordTextBoxX.Text.Substring(MyLoop, 1) >= "9" Then
MsgBox("invalid")
End If
Next