|
注:以下代码的前提是4位并为数字类型,而且没有算是否闰年,具体可自己完善
sub CheckDate(sData)
if cint(Left(cstr(sData),2))>0 and cint(Left(cstr(sData),2))<13 then
select case cint(Left(cstr(sData),2))
case 1,3,5,7,8,10,12
if cint(Right(cstr(sData),2))>0 and cint(Right(cstr(sData),2))<32 then
msgbox "pass"
else
msgbox "fail"
end if
case 4,6,9,11
if cint(Right(cstr(sData),2))>0 and cint(Right(cstr(sData),2))<31 then
msgbox "pass"
else
msgbox "fail"
end if
case 2
if cint(Right(cstr(sData),2))>0 and cint(Right(cstr(sData),2))<30 then
msgbox "pass"
else
msgbox "fail"
end if
end select
else
msgbox "fail"
end if
end sub
'Do test
myData="0323"
CheckDate(mData) |
|