private sub cmdOK_Click() if len(text1.text)<15 or len(text1.text>18) then msgbox "错误" exit sub end if 输入正确 继续处理 end sub ================================ 欢迎大家来:http://www.myvc.net/ ================================
只要在文本框市区焦点是写入下代码即可。 Private Sub Text1_LostFocus() If Len(Text1) < 15 Or Len(Text1) > 18 Then MsgBox ("error") Text1.SetFocus End If End Sub
private sub cmdOK_Click() if len(text1.text)<15 or len(text1.text>18) then
msgbox "错误"
exit sub
end if 输入正确
继续处理
end sub
================================
欢迎大家来:http://www.myvc.net/
================================
Private Sub Text1_LostFocus()
If Len(Text1) < 15 Or Len(Text1) > 18 Then
MsgBox ("error")
Text1.SetFocus
End If
End Sub