引用Microsoft VBScirpt Regular ExpressionsDim myReg As RegExpPrivate Sub Form_Load() Set myReg = New RegExp myReg.IgnoreCase = True myReg.Pattern = "^[\w-\.]+@\w+\.\w+$" End SubPrivate Sub Text1_Validate(Cancel As Boolean) Cancel = Not myReg.Test(Text1) End Sub
Private Sub Command2_Click() If myReg.Test(Text1) = False Then MsgBox "wrong" End Sub
Set myReg = New RegExp
myReg.IgnoreCase = True
myReg.Pattern = "^[\w-\.]+@\w+\.\w+$"
End SubPrivate Sub Text1_Validate(Cancel As Boolean)
Cancel = Not myReg.Test(Text1)
End Sub
If myReg.Test(Text1) = False Then MsgBox "wrong"
End Sub