【发布时间】:2017-08-10 06:23:11
【问题描述】:
我有一个计时器,它会在每 86400000 秒(每 24 小时,因此每天)之后打勾,以将新的一天放入 DateTimePicker,dtPicker1。不幸的是,在计时器滴答作响后,除了日期之外,结果还会带来一天中的时间(例如 2017-03-18 00:00:05,而不是 2017-03-18 。当我使用消息框检查输出时,我得到没有时间但第二天的日期(在计时器滴答后,它会添加时间,因此代码失败。
`'tick 每 86400000 毫秒(一天) dtPicker1.Enabled = True
dtPicker1.Text = ""
Dim mFmt As String = "yyyy-MM-dd"
dtPicker1.Format = DateTimePickerFormat.Custom
dtPicker1.CustomFormat = mFmt
dtPicker1.Text = ""
Dim st As Date = Today.AddDays(-1).ToShortDateString
Dim cf As String = Today.AddDays(-1)
Dim dr As String = cf.Substring(3, 2)
'MsgBox(dr)
Dim de As String = cf.Substring(6, 4)
Dim fg As String = cf.Substring(3, 2)
Dim ab As String = cf.Substring(0, 2)
'MsgBox(de & "-" & fg & "-" & ab, vbInformation, "Here you Go")
dtPicker1.Value = de & "-" & fg & "-" & ab`
我们将不胜感激。
【问题讨论】:
-
您无需将
DateTime类型转换为字符串即可访问日、月、年、时、分、秒、毫秒。检查它的属性
标签: vb.net date timer datetimepicker