转: 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
用isdate判断if isdate(input) then .... else ... 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
....
else
...
end if