text1是手机号码输入文本框 text2是电子邮件输入文本框 command1检查按钮 Private Sub Command1_Click() If Len(Text1) <> 11 Then MsgBox "请输入11位手机号", 64, "提示" Else For i = 1 To 11 If Asc(Mid(Text1, i, 1)) < 48 Or Asc(Mid(Text1, i, 1)) > 57 Then MsgBox "只能输入数字", 64, "提示" Exit For End If Next End IfIf Len(Text2) - Len(Replace(Text2, "@", "")) = 0 Then MsgBox "格式错误", 64, "提示" End If End SubPrivate Sub Form_Load() Text1.MaxLength = 11 End Sub
text2是电子邮件输入文本框
command1检查按钮
Private Sub Command1_Click()
If Len(Text1) <> 11 Then
MsgBox "请输入11位手机号", 64, "提示"
Else
For i = 1 To 11
If Asc(Mid(Text1, i, 1)) < 48 Or Asc(Mid(Text1, i, 1)) > 57 Then
MsgBox "只能输入数字", 64, "提示"
Exit For
End If
Next
End IfIf Len(Text2) - Len(Replace(Text2, "@", "")) = 0 Then
MsgBox "格式错误", 64, "提示"
End If
End SubPrivate Sub Form_Load()
Text1.MaxLength = 11
End Sub
小于零或大于256的可能是中文字哦