-
Private Function IsEmail(email As String) As Boolean
Dim firstAt As Integer
Dim firstDot As Integer
firstAt = InStr(1, email, "@")
firstDot = InStr(1, email, ".")
If firstAt > 0 And firstDot > 0 Then
'Check for other "@"
If InStr(firstAt + 1, email, "@") > 0 Then
IsEmail = False
Exit Function
Else
'Check for other "."
If InStr(firstDot + 1, email, ".") > 0 Then
IsEmail = False
Exit Function
End If
End If
IsEmail = True
Else ' "@" or "." is missing
IsEmail = False
End If
End Function
U can takecare of empty text before pass to the function.
ex) if Len(text1) = 0 then
msgbox "No input"
text1.Setfocus
else
if not IsEmail(text1) then _
MsgBox "Wrong format!"
end if
Joon
HTH
-
Wow....thanks you guys!
------------------
CompuGEEK
-
try the like command:
my email is [email protected]
If Not MyEmail like "*@*.*" then MSgbox "This is not a valid email!"
the first * in the string above detects and ignores the first part of the email in my case it would be:
wossnamex
the @ detects and logs the @ in the email.
the next asterisk ignores the talk21 part.
then the decimal.
then it makes sure there is something after the decimal, (com )
this quick enough for ya? :)
------------------
Wossname, part time string function god!
Email me: [email protected] :)
[This message has been edited by wossname (edited 12-29-1999).]
-
You 'da Man, Wossman!
------------------
CompuGEEK
-
N O T E :
Remember that most Mail Servers don't allow . in the username but SOME do. and also make sure your "filter" doesn't say that [email protected] or [email protected]
some mail address's are like that!!!
Hope this is helpful
-------------
ALF
ALFWare
-
I like your approach wossname, but I altered it a bit. Your function thinks "@." is a valid email address, but there has to be at least a character before the @, between @ and . and after the .
So I changed it in:
If Not MyEmail Like "*?@?*.?*" Then MsgBox "This is not a valid email!"
-
Is there a quick way (yeah right!) to check if an email address is in the proper format?
For instance, (I'm reading from a database)if you have email addresses being read from the Email field of the database:
me@aol
me@aolcom
[email protected]
none given
Is there a quick routine or function to filter out the improperly formatted ones?
Thanks
------------------
CompuGEEK
-
why not try using the instr command to check on the @ symbol and using it again to check a decimal place or more.
like:
if instr(,"@", The EMail Addess) <> "" and instr(,".", The EMail Address) <> "" then
Invalid email address
end if
I hope that helps!
------------------