I'm only learning right now and what I'm trying to do is to test a TextBox text to see if the user has entered a valid email address (if contains @ symbol)
So far I've got things right, but somehow I'm getting the error message "Make sure that the maximum index of a list is less than its size" and I don't know where I've gone wrong.
This is the code I'm using for this...
Where am I going wrong?
So far I've got things right, but somehow I'm getting the error message "Make sure that the maximum index of a list is less than its size" and I don't know where I've gone wrong.
This is the code I'm using for this...
VB.NET:
Dim email As String
Dim counter As Integer
email = Trim(TextBox2.Text)
For i = 0 To email.Length
If email.Chars(i) = "@" Then !The error highlights and points to this line!
counter = counter = 1
End If
Next i
If counter = 1 Then
MsgBox("Thank you for your email address")
ElseIf counter > 1 Then
MsgBox("Enter a valid email addres")
End If
Where am I going wrong?