' existence of '@'
If occurrenceOf(myEmail, "@") = 0 Then
isValidEmail = False
Exit Function
End If
' existence of '@' more than once.
If occurrenceOf(myEmail, "@") > 1 Then
isValidEmail = False
Exit Function
End If
' existence of '.'(dot).
If occurrenceOf(myEmail, ".") = 0 Then
isValidEmail = False
Exit Function
End If
' existence of space
If occurrenceOf(myEmail, " ") <> 0 Then
isValidEmail = False
Exit Function
End If
' the first char is digit
If Left$(myEmail, 1) Like "[0-9]" Then
isValidEmail = False
Exit Function
End If
' existence of . in the ID part, or x@.x pattern
If (InStr(1, myEmail, "@") + 1) >= InStrRev(myEmail, ".") Then
isValidEmail = False
Exit Function
End If
isValidEmail = True
End Function
Function occurrenceOf(source As String, char As String)
Dim i As Integer, j As Integer
Dim myCount As Integer
myCount = 0
i = InStr(1, source, char)
Do While i > 0
myCount = myCount + 1
i = InStr(i + 1, source, char)
Loop
occurrenceOf = myCount
End Function
This post has been edited by behailu: 06 March 2006 - 07:58 AM

New Topic/Question
Reply



MultiQuote



|