|
3#
楼主 |
发表于 2006-4-10 16:27:11
|
只看该作者
谢谢,我的代码如下,是判断EMAIL的有效性:
Public Function IsValidEmail(strEmail As String) As Boolean
Dim names, name, i, c
IsValidEmail = True
names = Split(strEmail, "@")
If( UBound(names) <> 1) Then
IsValidEmail = False
Exit Function
End If
For Each name In names
If( Len(name) <= 0 )Then
IsValidEmail = False
Exit Function
End If
For i = 1 To Len(name)
c = LCase(Mid(name, i, 1))
If (InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) )Then
IsValidEmail = False
Exit Function
End If
Next
If( Left(name, 1) = "." Or Right(name, 1) = ".") Then
IsValidEmail = False
Exit Function
End If
Next
If (InStr(names(1), ".") <= 0 )Then
IsValidEmail = False
Exit Function
End If
i = Len(names(1)) - InStrRev(names(1), ".")
If (i <> 2 And i <> 3 )Then
IsValidEmail = False
Exit Function
End If
If (InStr(strEmail, "..") > 0 )Then
IsValidEmail = False
Exit Function
End If
End Function感觉没少括号啊,提示的是这个函数少吗?谢谢
[ 本帖最后由 minliu 于 2006-4-10 17:08 编辑 ] |
|