Click to See Complete Forum and Search --> : ATTENTION: String function Guru's
jpark
Dec 29th, 1999, 12:27 AM
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
compuGEEK
Dec 29th, 1999, 12:31 AM
Wow....thanks you guys!
------------------
CompuGEEK
try the like command:
my email is wossnamex@talk21.com
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: wossnamex@talk21.com :)
[This message has been edited by wossname (edited 12-29-1999).]
compuGEEK
Dec 29th, 1999, 12:47 AM
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 me@myemail.gov.qld.au or me.lastname@yourass.here.there.com
some mail address's are like that!!!
Hope this is helpful
-------------
ALF
ALFWare
Frans C
Dec 29th, 1999, 12:59 AM
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!"
compuGEEK
Dec 29th, 1999, 11:36 AM
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
me@aol.com
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!
------------------
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.