'简单写一下,当然你可以根据你的要求写的更正规Private Sub Command1_Click() Dim i As Long If Len(Text1.Text) < 15 Or Len(Text1.Text) > 20 Then MsgBox "邮件地址长度不正确" Text1.SetFocus Exit Sub End If i = InStr(1, Text1.Text, "@") If i < 2 Then MsgBox "邮件格式不正确" Exit Sub Text1.SetFocus End If End Sub
在SQL SERVER中创建一个rule就行了。CREATE RULE email_rule AS emailaddr LIKE '%@%'
写错一点点CREATE RULE email_rule AS @emailaddr LIKE '%@%'用sp_bindrule可以将规则应用到特定表的特定列。exec sp_bindrule 'email_rule','mytable.emailaddr'
范围的规则这样写:CREATE RULE range_rule AS @range >= 15 AND @range < 20
Dim i As Long
If Len(Text1.Text) < 15 Or Len(Text1.Text) > 20 Then
MsgBox "邮件地址长度不正确"
Text1.SetFocus
Exit Sub
End If
i = InStr(1, Text1.Text, "@")
If i < 2 Then
MsgBox "邮件格式不正确"
Exit Sub
Text1.SetFocus
End If
End Sub
AS
emailaddr LIKE '%@%'
AS
@emailaddr LIKE '%@%'用sp_bindrule可以将规则应用到特定表的特定列。exec sp_bindrule 'email_rule','mytable.emailaddr'
AS
@range >= 15 AND @range < 20
真的非常谢谢!