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
Printable View
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
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