----- Original Message -----
From: "Neeraj Shinde" <
neeraj...@gmail.com>
To: <
neeraj...@gmail.com>
Sent: Tuesday, October 26, 2004 2:23 PM
Subject: E-mail address validation
> Dim gstr1 As String
> Dim lenstr As String
> Dim atchk As Boolean
> Dim decchk As Boolean
> Dim i As Integer
> Dim strs As String
> Dim stre As String
> Dim rags As String
> Dim hars As String
> Dim strinat As String
> Dim strindec As String
> Dim strmidat As String
> Dim strmiddec As String
> Dim ans As String
>
> '**********************************************************
> 'Email Validation: Allowed only small letters,numerals,@,.
> 'Email format should be "a@a.a"
> 'First checks for any @ Or . characters occures in string then
> 'findis the last and first character of the string
> 'finds "@." or ".@" are together then it is Correct Email format.
> 'Otherwise it is wrong email format.
> '**********************************************************
> Dim chkdec As String
> Dim count1 As Integer
> count1 = 0
> lenstr = Len(txt_email.Text)
> For i = 1 To lenstr
> chkdec = Mid(txt_email, i, (Len(txt_email) - ((lenstr) - 1)))
> If chkdec = "." Then
> count1 = count1 + 1
> If count1 >= 3 Then
> MsgBox "Wrong Email Format"
> txt_email.SetFocus
> Exit Function
> End If
> End If
> Next i
> atchk = InStr(1, txt_email.Text, "@")
> decchk = InStr(1, txt_email.Text, ".")
> If atchk = True And decchk = True Then
> For i = 1 To lenstr
> strs = Left(txt_email.Text, 1)
> stre = Right(txt_email.Text, 1)
> strinat = InStr(1, txt_email.Text, "@")
> strmidat = Mid(txt_email.Text, strinat, lenstr)
> strindec = InStr(1, txt_email.Text, ".")
> strmiddec = Mid(txt_email.Text, strindec, lenstr)
>
> If Val(strinat) > Val(strindec) Then
> MsgBox "Wrong Email Format"
> txt_email.SetFocus
> Exit Function
> End If
> ans = Mid(txt_email, strindec, (Len(strindec) + 1))
> If ans = ".." Then
> MsgBox "Wrong Email Format"
> txt_email.SetFocus
> Exit Function
> End If
> rags = Mid(strmidat, 1, 2)
> hars = Mid(strmiddec, 1, 2)
> Next i
> ' rags = Mid(Mid(txt_email.Text, InStr(1, txt_email.Text,
> "@"), lenstr), 1, 2)
> ' hars = Mid(Mid(txt_email.Text, InStr(1, txt_email.Text,
> "."), lenstr), 1, 2)
>
> If strs = "@" Or stre = "." Or strs = "@" Or stre = "." Then
> MsgBox "Wrong Email Format"
> txt_email.SetFocus
> Exit Function
> ElseIf rags = "@." Or hars = ".@" Then
> MsgBox "Wrong Email Format"
> txt_email.SetFocus
> Exit Function
> End If
>
> Else
> MsgBox "Wrong Email Format"
> txt_email.SetFocus
> Exit Function
>
> End If
>
>
> --
> Regards,
> Neeraj Shinde
> Email :
neeraj...@rediffmail.com
> URL :
http://www.neerajshinde.cjb.net