找出2个选定的DatePickers之间的差异 [英] Find difference between 2 selected DatePickers

查看:75
本文介绍了找出2个选定的DatePickers之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2012-VB中尝试了这么多错误。我只是想在我的两个datepicker对象(DateIn& DateOut)中找到所选日期之间的差异。如果差异小于7,我希望选中一个复选框,大于7天,取消选中。我在这个网站上找到的所有解决方案都没有帮助。

I get so many errors from this trying this in VS2012-VB. I simply want to find the difference between the selected dates in my two datepicker objects (DateIn & DateOut). If the difference is less than 7 I want a checkbox to be checked, greater than 7 days, unchecked. None of the solutions I have found on this site have helped at all.

Private Sub RushOrder()
    If DateOut.SelectedDate - DateIn.SelectedDate < TimeSpan.FromDays(7) Then
        chkRush = True
    Else
        chkRush = False
    End If
End Sub

推荐答案

尝试:



Try :

Dim ts as TimeSpan = DateOut.Value - DateIn.Value

If (ts.TotalDays > 7)
   '' Do something when difference is greater than 7 days
Else
   '' Do something when the difference is less than 7 days
End If





希望这会有所帮助。



Hope this helps.


这篇关于找出2个选定的DatePickers之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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