why not using a DateTimePicker if you want a date input?or try to use Microsoft Masked Edit Control, and use a Mask like "####-##-##", if you want an exact date, you need to do some checking in its Change event
用 Microsoft Masked Edit Control 6.0 部件,设置mask属性为 ####-##-##
1.如果你用了数据库,那么该字段可以设定为日期/时间 2.Microsoft Masked Edit Control 6.0 部件,设置mask属性为 ####-##-##
应该允许用户输入所有合法的日期型数据,可以在text1的lostfocus事件中格式化你要的格式: private sub text1_lostfocus() if not isdate(text1.text) then msgbox "请输入日期型数据!",48,"提示" text1.setfocus else text1.text=format(text1.text,"yyyy-mm-dd") end if end if
Microsoft Masked Edit Control 6.0 部件,设置mask属性为 ####-##-##
2.Microsoft Masked Edit Control 6.0 部件,设置mask属性为 ####-##-##
用了数据库,就得加个判断输入的语句或函数,要是他输错了格式,回报错的
之前也可以用isdate(datevalue)来判断是不是有效的日期!!
或者直接用DTpicker
private sub text1_lostfocus()
if not isdate(text1.text) then
msgbox "请输入日期型数据!",48,"提示"
text1.setfocus
else
text1.text=format(text1.text,"yyyy-mm-dd")
end if
end if