CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2001
    Posts
    9

    validate email address

    hi there, my VB application allow the user to enter his/her email address..how do i check whether the email that the user entered is of the right format...?? please help..thanks




  2. #2
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: validate email address

    Well .. a valid email should at least be in this format [email protected], so you can use the sample code below to check:


    function ValidateEmail(szEmail as string) as boolean
    dim nInd as integer
    dim bValid as boolean

    bValid = false ' by default - not valid
    nInd = instr(1, szEmail, "@") ' get the @
    if (nInd > 0) then
    ' found the @ then check for .
    nInd = instr(nInd, szEmail, ".") ' get the .
    if (nInd > 0) then
    ' found - probably a valid email
    bValid = true
    end if
    end if

    ValidateEmail = bValid
    end function




    -Cool Bizs

    Good Luck,
    -Cool Bizs

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

Featured