|
发表于 2013-6-24 16:18
|
显示全部楼层
本楼为最佳答案
- Function CheckDate(strText As String) As Boolean
- Dim objText As MSForms.TextBox
- Set objText = Me.Controls(strText)
- With objText
- If .Text = "" Or .Text = "长期" Then Exit Function
- If Not IsDate(Format(.Text, "####-##-##")) Then '检查日期格式
- CheckDate = True
- MsgBox "输入格式有误"
- .Text = ""
- .SetFocus
- Else
- If DateDiff("d", Format(.Text, "####-##-##"), Date) > 0 Then
- CheckDate = True
- MsgBox "证件已过期,请更新"
- .Text = ""
- .SetFocus
- End If
- End If
- End With
- End Function
复制代码 |
|