如果条件,datetimepicker问题 [英] datetimepicker problem if conditions

查看:112
本文介绍了如果条件,datetimepicker问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有两个datetimepicker.

dtp1和dtp2

想要条件为真
dtp1 = 2011年1月1日
dtp2 = 2011年4月1日


如果dtp2的值介于2011年1月1日至2011年7月1日之间(距离dtp1的日期提前7天),则条件为true.


如果
dtp1 = 2011年1月1日
dtp2 = 2011年9月1日
然后条件为false

hi all,

i have two datetimepicker.

dtp1 and dtp2

want condition true
dtp1 = 1-1-2011
dtp2 = 4-1-2011


if dtp2''s value is between 1-1-2011 to 7-1-2011 (7 days ahead from dtp1''s date) then condition true.


if
dtp1 = 1-1-2011
dtp2 = 9-1-2011
then condition false

推荐答案

Dim ts As TimeSpan 
Dim condition As Boolean 
ts = dtp1.Value.Subtract(dtp2)
if ts.Days >= 7 Then Condition =True


使用TimeSpan 类计算两个日期之间的差异.
浏览 [
Use the TimeSpan class to calculate the differences between the two dates.
Go through this[^] for an example.


这篇关于如果条件,datetimepicker问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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