Validating an e-mail address

Hi,

I was wondering if anyone has any quick routines on validating e-mail addresses in VB, ie., checking there is one @, at least one '.', no spaces etc.

Any help would be greatly appreciated.

Ben
BennieAsked:
Who is Participating?
 
NinibiniCommented:
check out
http://161.58.186.98/misc/tip519.html
at vb-world.net
the have a sample posted on their site.

0
 
vim_asteyaCommented:
u can use the instr function.
I did the validation using this function
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
If strEmail like "*@*.*" and Instr(1,strEmail," ") = 0 Then
  'email seems valid
End If

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
vim_asteyaCommented:
Dim v1, v2
If Len(email.Text) = 0 Then
    DoEvents
ElseIf Len(email.Text) > 0 Then
    v2 = (InStr(1, email.Text, "@", vbTextCompare))
    v1 = (InStr(1, email.Text, ".", vbTextCompare))
       
        If ((v2 > 0) And (v1 > 0)) Then
            DoEvents
        Else
            MsgBox "Invalid ID", , "Email"
            email.SetFocus
            email.Text = ""
        End If
End If
try this,it worked for me
0
 
Ryan ChongCommented:
0
 
BennieAuthor Commented:
Thanks very much everyone for suggestions. This one seems to have worked out the best.

Ben
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.