by Allan Iman (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 13th June 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This code validates email address. Use the ValidateEmail() function.
Dim j As Integer
If txtEmalAd.Text = "" Then GoTo ByPass1 'allow zero length
For j = 1 To Len(n)
If Mid(n, j, 1) = "@" Then 'check if address has @ sign
If Mid(n, j + 1, 1) = "." Then 'if @ sign is followed by period(.)
ValidateEmail = False
Exit For
End If
If j = 1 Then
ValidateEmail = False
Else
If ValidateExt(j, n) = True Then 'validate extention
ByPass1:
ValidateEmail = True
Else
ValidateEmail = False
End If
End If
Exit For
Else
ValidateEmail = False
End If
Next j
End Function
Function ValidateExt(Start As Integer, n As String) As Boolean
Dim j As Integer
Dim ext As String
Dim depot As String
For j = Start To Len(n)
depot = Mid(n, j, 1)
If depot = "." Then
ext = depot
ext = ext + Mid(n, j + 1, Len(n) - j)
If ext = ".com" Or _
ext = ".org" Or _
ext = ".net" Or _
ext = ".com.ph" Then
ValidateExt = True
Else
ValidateExt = False
End If
Exit For
End If
Next j
End Function
No comments have been posted about This code validates email address. Use the ValidateEmail() function.. Why not be the first to post a comment about This code validates email address. Use the ValidateEmail() function..