判断字符串是否是合法的EMail
public Function is valid email(strEmail As String)As Boolean
Dim names,name,I,c
is valid email = True
names = Split(strEmail," @ ")
如果UBound(names) 1,则
is valid email = False
Exit函数
End If
对于“名称”中的每个名称
If Len(name)is valid email = False
Exit函数
End If
for I = 1 To Len(name)
c = LCase(Mid(name,I,1))
if InStr(" abcdefghijklmnopqrstuvwxyz _-",c) IsValidEmail = False
Exit函数
End If
Next
If Left(name,1) = " "或Right(name,1) = " "那么
is valid email = False
Exit函数
End If
然后
If InStr(names(1)," ")IsValidEmail = False
Exit函数
End If
I = Len(names(1))-instr rev(names(1)," ")
如果i 2和i 3,那么
is valid email = False
Exit函数
End If
If InStr(strEmail,“.”)> 0,则
is valid email = False
Exit函数
End If
结束功能
位律师回复
0条评论