hi I am working on this email validation and was wondering if you guys could help. I am trying to validate the user does not enter more than one '@' or '.' . Assuming of course that most emails contain only one ampersand and period. below i have included my code but it does not work correctly. Please help!!
thanks in advance,
===========================================================
Private Function CheckEmail()
Dim strMsg As String
Dim iX As Long
iX = InStr(1, strEmail, "@", vbBinaryCompare)
If iX Then
If InStr(iX, strEmail, "@", vbBinaryCompare) Then
strMsg = "Only 1 '@' for Email Address."
If InStr(iX, strEmail, ".", vbBinaryCompare)Then
If InStr(iX, strEmail, ".", vbBinaryCompare) Then
strMsg = "Only 1 period for Email Address."
Else
bValidEmail = True
End If
End If
end if
End If
If bValidEmail = False Then
MsgBox strMsg, vbOKOnly
End If
End Function
thanks in advance,
===========================================================
Private Function CheckEmail()
Dim strMsg As String
Dim iX As Long
iX = InStr(1, strEmail, "@", vbBinaryCompare)
If iX Then
If InStr(iX, strEmail, "@", vbBinaryCompare) Then
strMsg = "Only 1 '@' for Email Address."
If InStr(iX, strEmail, ".", vbBinaryCompare)Then
If InStr(iX, strEmail, ".", vbBinaryCompare) Then
strMsg = "Only 1 period for Email Address."
Else
bValidEmail = True
End If
End If
end if
End If
If bValidEmail = False Then
MsgBox strMsg, vbOKOnly
End If
End Function