access窗体中文本框的值必须是邮箱格式 40
用ACCESS做了个注册系统,其中有个文本框(Text1)是需要用户填写邮箱地址的,当我点击“立即注册(command1)”键的时候,如果文本框(Text1)不是邮箱格式...
用ACCESS做了个注册系统,其中有个文本框(Text1)是需要用户填写邮箱地址的,当我点击“立即注册(command1)”键的时候,如果文本框(Text1)不是邮箱格式就报错。
望高手指教,请详细写一下,谢谢了! 展开
望高手指教,请详细写一下,谢谢了! 展开
2个回答
展开全部
这是一个VBA函数,判读一个字符串是否符合邮件格式。
Public Function is_email(email As String) As Boolean
is_email = False
Dim i As Integer, j As Integer
Dim c As Integer
Dim part() As String
part = Split(email, "@")
If UBound(part) <> 1 Then Exit Function
For i = 0 To UBound(part)
If Len(part(i)) = 0 Then Exit Function
Next
For i = 1 To Len(part(0))
c = Asc(Mid(part(0), i, 1))
If Not (c >= Asc("a") And c <= Asc("z") Or c >= Asc("A") And c <= Asc("Z") Or c >= Asc("0") And c <= Asc("9") Or c = Asc("_")) Then
Exit Function
End If
Next
part = Split(part(1), ".")
For i = 0 To UBound(part)
If Len(part(i)) = 0 Then Exit Function
For j = 1 To Len(part(i))
c = Asc(Mid(part(i), j, 1))
If Not (c >= Asc("a") And c <= Asc("z") Or c >= Asc("A") And c <= Asc("Z") Or c >= Asc("0") And c <= Asc("9") Or c = Asc("_")) Then
Exit Function
End If
Next
Next
is_email = True
End Function
Public Function is_email(email As String) As Boolean
is_email = False
Dim i As Integer, j As Integer
Dim c As Integer
Dim part() As String
part = Split(email, "@")
If UBound(part) <> 1 Then Exit Function
For i = 0 To UBound(part)
If Len(part(i)) = 0 Then Exit Function
Next
For i = 1 To Len(part(0))
c = Asc(Mid(part(0), i, 1))
If Not (c >= Asc("a") And c <= Asc("z") Or c >= Asc("A") And c <= Asc("Z") Or c >= Asc("0") And c <= Asc("9") Or c = Asc("_")) Then
Exit Function
End If
Next
part = Split(part(1), ".")
For i = 0 To UBound(part)
If Len(part(i)) = 0 Then Exit Function
For j = 1 To Len(part(i))
c = Asc(Mid(part(i), j, 1))
If Not (c >= Asc("a") And c <= Asc("z") Or c >= Asc("A") And c <= Asc("Z") Or c >= Asc("0") And c <= Asc("9") Or c = Asc("_")) Then
Exit Function
End If
Next
Next
is_email = True
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询