|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
DateTimePicker
Below is the code I have written for a click event to show the difference in days between two dates selected from two DateTimePickers. If I choose Aug 30 and Aug 30, it shows zero days. Can someone please help me adjust my code so that the number of days off start at one not zero?
Dim x As Integer x = DateDiff(DateInterval.Day, DateTimePicker1.Value, DateTimePicker2.Value) MessageBox.Show("# of days scheduled off is: " & x & " days") Thank you, |
|
#2
|
|||
|
|||
|
just add one to the DateDiff value.
also for future posts this is a vb.net question and should go in the .Net (ASP.Net, VB.Net, C#) section.
__________________
Programmer's Corner |
|
#3
|
|||
|
|||
|
DateTimePicker
I have tried putting +1 at the end of the DateTimePicker2.Value and the DateTimePicker1.Value. I have also tried putting +1 outside of the brackets as well but to no avail.
Below are the examples I have tried. Dim x As Integer x = DateDiff(DateInterval.Day, DateTimePicker1.Value, DateTimePicker2.Value) + 1 MessageBox.Show("# of days scheduled off is: " & x & " days") Dim x As Integer x + 1= DateDiff(DateInterval.Day, DateTimePicker1.Value, DateTimePicker2.Value) MessageBox.Show("# of days scheduled off is: " & x & " days") Dim x As Integer x = DateDiff(DateInterval.Day, DateTimePicker1.Value, DateTimePicker2.Value) MessageBox.Show("# of days scheduled off is: " & x + 1 & " days") Any more ideas please? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > DateTimePicker |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|