Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
VB
Private Sub RushOrder()
    If DateOut.SelectedDate - DateIn.SelectedDate < TimeSpan.FromDays(7) Then
        chkRush = True
    Else
        chkRush = False
    End If
End Sub
Posted
Updated 8-Feb-13 3:52am
v2
Comments
CHill60 8-Feb-13 9:51am    
Post the code that is producing so many errors so that we can try to help

1 solution

Try :

VB
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.
 
Share this answer
 
Comments
Sean Donnahoe 8-Feb-13 9:54am    
Actually, this doesn't help much. .Value is not a property or method of DatePicker object. At least on my machine. Am I missing a dependency or something?
phil.o 8-Feb-13 11:56am    
I don't remember, and I don't have any IDE installed on this computer. Just find the property of your DateTimePicker object that holds the DateTime value ; auto-completion should help you here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900