验证日期时间选择器输入 [英] Validate a Date Time Picker Input

查看:79
本文介绍了验证日期时间选择器输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我有一个带有三个日期选择器控件的表单。如何验证用户是否实际选择了某个日期(即使是今天)。日期通常在当前日期之前约一个月至一个月的范围内。



谢谢



R

解决方案

当您使用DateTimePicker控件时,它们始终显示有效的日期时间 - 这就是整点。他们从未显示或返回无效日期。



如果您需要知道用户已更改(或更改并更改回来),请处理ValueChanged事件。


''你好



''你可以创建一个像
这样的字符串
Dim strDate as字符串



''做这样的事情(对不起,但我不知道我头上的命令)

strDate = YourDateTimePicker.SelectedDate.ToString ()



''验证:

如果strDate.Length> 0然后

''用户选择了一个日期

''你可以继续

否则

''他没有选择约会

''惩罚他!

结束如果



希望它对你有所帮助:)

Hi
I have a form with three date picker controls. How can I validate that a user has actually selected a date (even if it is today). The dates will typically fall within range of about a month before to a month after the current date.

Thanks

R

解决方案

When you use a DateTimePicker control, they always show a valid date time - that''s the whole point. They never show or return an invalid date.

If you need to know that the user has changed it (or changed it and changed it back) then handle the ValueChanged event.


'' Hello

'' You can create a string like
Dim strDate as string

''Do something like this (sorry but i dont know the command from my head)
strDate = YourDateTimePicker.SelectedDate.ToString()

'' Validation:
If strDate.Length > 0 then
''the user has selected a date
''you can continiue
Else
''he didnt select a date
''punish him!
End If

Hope it helped you a bit :)


这篇关于验证日期时间选择器输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆