Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB VB.NET
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
Posted 8-Feb-13 4:44am
Edited 8-Feb-13 4:52am
v2
Comments
CHill60 at 8-Feb-13 9:51am
   
Post the code that is producing so many errors so that we can try to help

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Sean Donnahoe at 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 at 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)

  Print Answers RSS
0 BillWoodruff 360
1 Mathew Soji 309
2 DamithSL 225
3 Afzaal Ahmad Zeeshan 202
4 Maciej Los 190
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100