Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
E-mail address validation....
Author:
M Raghavendra Rao
E-mail:
Click to e-mail author
Submitted:
5/28/2003
Version:
VB5
Compatibility:
VB5, VB6
Category:
Internet Programming
Views:
14257
E-mail address validation.
Declarations:
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
Code:
'********************************************************** '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
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement