I have vb form tht accepts user data.I need to check whether user enters emailid in the correct format ?Please provide suggestion .Thanks in advance

try this
first define a function

Private Function IsValidEmailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean
   sEmail = LCase(Trim(sEmail))
   If Len(sEmail) < 7 Then
      sReason = "Too short"
   ElseIf sEmail Like "*[!0-9a-z@._+-]*" Then
      sReason = "Invalid character"
   ElseIf Not sEmail Like "*@*.*" Then
      sReason = "Missing the @ or ."
   ElseIf sEmail Like "*@*@*" Then
      sReason = "Too many @"
   ElseIf sEmail Like "[@.]*" Or sEmail Like "*[@.]" _
      Or sEmail Like "*..*" Or Not sEmail Like "?*@?*.*?" Then
      sReason = "Invalid format"
   Else
      Dim n As Integer
      n = Len(sEmail) - InStrRev(sEmail, ".")
      If n > 3 Then
         sReason = "Suffix too long"
      ElseIf n < 2 Then
         sReason = "Suffix too short"
      Else
         sReason = Empty
         IsValidEmailAddress = True
      End If
   End If
End Function

here call it (Normally On the lostfocus event)

Private Sub Text1_LostFocus()
Dim bool As Boolean, reason As String
bool = IsValidEmailAddress(Me.Text1.Text, reason)
If (bool <> True) Then
MsgBox reason
End If
End Sub

Hope this helps you . . .

its showing error for proper format of email

thank you for resolving :)kindly ignore the former message

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.