I'm trying to validate the correct format for a phone number in a text box: (000) 000-0000
For a test, i made it so that a messagebox shows up saying "correct" if the format is correct. This test works well WHEN the format is correct. BUT when the format IS NOT correct, I keep getting an error saying that the index was out of the array.
How can I fix it? Here's what I have...
ElseIf phonenumbertxtbox.Text.Length <> 0 Then
If phonenumbertxtbox.Text.Chars(0) <> "(" And phonenumbertxtbox.Text.Chars(4) <> ")" Then
MessageBox.Show("incorrect")
Else
MessageBox.Show("correct")
End If
I only tested the (000) because I wanted to see if i could get it to work before completing the code.
Please help! Thank you!