本文介绍了如何更改/设置DateTimePicker值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试设置/更改DateTimePicker值(使用vb.net),但无法解决该问题。
I am trying to set / change the DateTimePicker value (using vb.net) but can't work out how to do it.
我添加了控件进入页面,我尝试使用以下代码,但是它不起作用,并且我无法弄清楚如何在运行时设置值。
I have added the control to the page and I have tried using the following code but it doesn't work and I can't work out how to set the value during run-time.
DateTimePicker1.Value = Now.Day & "-" & Now.Month & "-" & Now.Year
控件的格式设置为Long,第一次加载时看起来像这样:
The format of the control is set to Long and it looks like this when first loaded:
2013年2月26日,星期二
但我无法解决
基于上面的代码,我得到的错误是:
The error I get based on my code above is:
转化从字符串 26-2-2013到日期类型无效。
有人有任何想法吗?
推荐答案
我最终通过执行以下操作使其工作:
I ended up getting it working by doing the following:
DateTimePicker1.Value = New Date(2013, 2, 26)
我正在错误地加载值
这篇关于如何更改/设置DateTimePicker值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!