重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Dim dt as Date
坚守“ 做人真诚 · 做事靠谱 · 口碑至上 · 高效敬业 ”的价值观,专业网站建设服务10余年为成都成都发电机维修小微创业公司专业提供成都定制网页设计营销网站建设商城网站建设手机网站建设小程序网站建设网站改版,从内容策划、视觉设计、底层架构、网页布局、功能开发迭代于一体的高端网站建设服务。
Dim s="2009-12-32"
if NOT Date.TryPhrase(s,dt) then
'日期无效代码
end if
Private Sub Command1_Click()
Dim myYear, myMonth, myDay, myWeek, Days As Integer
Dim myDate As StringmyYear = Val(TextY.Text)
myMonth = Val(TextM.Text)
myDay = Val(TextD.Text)
If myYear 1980 Or myYear 9999 Then
MsgBox "输入的年份应在[1980, 9999]之间"
Exit Sub
End If
If myMonth 1 Or myMonth 12 Then
MsgBox "输入的月份应在[1, 12]之间"
Exit Sub
End If
Select Case myMonth
Case 1, 3, 5, 7, 8, 10, 12
Days = 31
Case 4, 6, 9, 11
Days = 30
Case 2
If (myYear Mod 4 = 0) And (myYear Mod 100 0) Or (myYear Mod 400 = 0) Then
Days = 29
Else
Days = 28
End If
End SelectIf myDay 1 Or myDay Days Then
MsgBox "输入的日期应在[1, " + Format(Days) + "]之间"
Exit Sub
End IfmyDate = Format(myYear) + "/"
If myMonth 10 Then
myDate = myDate + "0"
End If
myDate = myDate + Format(myMonth) + "/"
If myDay 10 Then
myDate = myDate + "0"
End If
myDate = myDate + Format(myDay)
End Sub
If IsDate(Text1.Text) Then
MsgBox "正确的日期格式"
Else
MsgBox "错误的日期格式"
End If
要再高级点就是:
If IsDate(Text1.Text) Then
If Format(Text1.Text, "yyyy-m-d") = Text1.Text Then
MsgBox "正确的日期格式"
Else
MsgBox "不是指定的日期格式(yyyy-m-d)"
End If
Else
MsgBox "错误的日期格式"
End If