Results 1 to 8 of 8

Thread: ATTENTION: String function Guru's

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 1999
    Location
    Garden Grove, CA, Orange
    Posts
    55

    Post


    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

  2. #2
    Hyperactive Member compuGEEK's Avatar
    Join Date
    May 1999
    Location
    Mpls,MN,USA
    Posts
    281

    Post

    Wow....thanks you guys!

    ------------------
    CompuGEEK


  3. #3
    Guest

    Post

    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).]

  4. #4
    Hyperactive Member compuGEEK's Avatar
    Join Date
    May 1999
    Location
    Mpls,MN,USA
    Posts
    281

    Post

    You 'da Man, Wossman!

    ------------------
    CompuGEEK


  5. #5
    Guest

    Post

    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

  6. #6
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    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!"

  7. #7
    Hyperactive Member compuGEEK's Avatar
    Join Date
    May 1999
    Location
    Mpls,MN,USA
    Posts
    281

    Post

    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

  8. #8
    Guest

    Post

    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!


    ------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width