if (((Mid(aa, 1, 4)>1000) and (Mid(aa, 1, 4)<9999)) and ((Mid(aa, 5, 2)>0 and (mid(aa, 5, 2)<13)) and ((Mid(aa, 7, 2)>0) and (Mid(aa, 7, 2)<31) )) =true then
msgbox"对"
else
msgbox"错"
end if
dim str as string
str="041009"
if isdate(Right(Left(str, Len(str) - 4), Len(str) - 4) & "-" & Right(Left(str, Len(str) - 2), 2) & "-" & Right(str, 2)) then
'时间字段
end if
private sub text1_lostfocus()
if trim(text1.text)<>"" then
if not isdate(text1.text) then
msgbox "请输入日期型数据!",48,"提示"
text1.setfocus
exit sub
else
text1.text=format(text1.text,"YYYY-MM-DD")
end if
end if
end sub
Dim aa As String
aa = "20041009"
aa = Mid(aa, 1, 4) & "-" & Mid(aa, 5, 2) & "-" & Mid(aa, 7, 2)
'MsgBox aa
If IsDate(aa) = True Then
MsgBox "是有效的日期"
Else
MsgBox "不是有效的日期"