2010/11/9 neil johnson <neil.jh...@googlemail.com> > > > > > > Hi, > > I make textbox in user form. The label of this texbox email . When i enter > the email address with out using or forget @ and Dot(.). It should give me > msg . please use valid email Id . > > > Wht will be code of this . Please find the attache sheet. > > Private Sub CommandButton1_Click() If isMail(Me.TextBox1.Value) Then 'email ok Else MsgBox "mail not valid" End If End Sub Function isMail(sMail As String) As Boolean Dim re As Object Set re = CreateObject("vbscript.regexp") re.Pattern = "^\w+([-+.]\w+)" & _ "*...@\w+([-.]\w+)" & _ "*\.\w+([-.]\w+)*$" isMail = re.test(sMail) End Function
regards r -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts