Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 244,284 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,030 people online right now. Registration is fast and FREE... Join Now!




datepicker - If Statements

 
Reply to this topicStart new topic

datepicker - If Statements, Prevent a date from being picked less than current date?

4x4pirate
8 Nov, 2008 - 09:56 AM
Post #1

D.I.C Head
**

Joined: 18 Oct, 2006
Posts: 52


My Contributions
I figured out to calculate two dates DAYS from each other..

But how do you write the IF statement so that if the day you picked before the date you checked in, it throws a flag?

I know it would be something like

If d1 < Current time... (I cant figure out the current time bit)



CODE
Private Sub DateTimeCheckOutPicker_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimeCheckOutPicker.ValueChanged
        'Calculate the number of days the guest is staying at the hotel.
        Dim d1, d2 As Date
        d1 = Me.DateTimeCheckInPicker.Value  'Sets d1 as Check In date
        d2 = Me.DateTimeCheckOutPicker.Value 'd2 as Checkout Date
        If d1 > d2 Then
            MessageBox.Show("Error, Check in date must be before checkout")
            Me.DateTimeCheckInPicker.Focus()
        Else
            strNumberofnights = CStr(d2.Subtract(d1).Days) ' Compares two dates and subracts the days
        End If


User is offlineProfile CardPM
+Quote Post


4x4pirate
RE: Datepicker - If Statements
8 Nov, 2008 - 11:20 AM
Post #2

D.I.C Head
**

Joined: 18 Oct, 2006
Posts: 52


My Contributions
Also, Since I am using DatePicker to checkin people, and datepicker to checkout picker, how can I make DatePickerCheckIn to accept the current date if the DatePickerCheckIn value IS NOT changed?


User is offlineProfile CardPM
+Quote Post

Pwn
RE: Datepicker - If Statements
8 Nov, 2008 - 01:07 PM
Post #3

D.I.C Regular
***

Joined: 25 Nov, 2007
Posts: 319



Thanked: 12 times
My Contributions
datepicker should have a min and max value, just set the min value to today, you should be good.
Also, it should default to today's date, so if you just get the value it should be today.

This post has been edited by Pwn: 8 Nov, 2008 - 01:09 PM
User is offlineProfile CardPM
+Quote Post

4x4pirate
RE: Datepicker - If Statements
8 Nov, 2008 - 01:48 PM
Post #4

D.I.C Head
**

Joined: 18 Oct, 2006
Posts: 52


My Contributions
QUOTE(Pwn @ 8 Nov, 2008 - 01:07 PM) *

datepicker should have a min and max value, just set the min value to today, you should be good.
Also, it should default to today's date, so if you just get the value it should be today.



How would I type that? I don't know that code
User is offlineProfile CardPM
+Quote Post

4x4pirate
RE: Datepicker - If Statements
8 Nov, 2008 - 02:05 PM
Post #5

D.I.C Head
**

Joined: 18 Oct, 2006
Posts: 52


My Contributions
Got it.. smile.gif

DateTimeCheckInPicker.MinDate = dtmSystemDate
DateIN = DateTimeCheckInPicker.Value
If DateIN > dtmSystemDate Then
MessageBox.Show("Dubmass")
User is offlineProfile CardPM
+Quote Post

4x4pirate
RE: Datepicker - If Statements
8 Nov, 2008 - 02:19 PM
Post #6

D.I.C Head
**

Joined: 18 Oct, 2006
Posts: 52


My Contributions
QUOTE(4x4pirate @ 8 Nov, 2008 - 02:05 PM) *

Got it.. smile.gif

DateTimeCheckInPicker.MinDate = dtmSystemDate
DateIN = DateTimeCheckInPicker.Value
If DateIN > dtmSystemDate Then
MessageBox.Show("Dubmass")






How do I set the minimum on DateTimeCheckOutPicker.MinDate = dtmSystemDate (PLUS ONE DAY)
User is offlineProfile CardPM
+Quote Post

Pwn
RE: Datepicker - If Statements
8 Nov, 2008 - 03:05 PM
Post #7

D.I.C Regular
***

Joined: 25 Nov, 2007
Posts: 319



Thanked: 12 times
My Contributions
QUOTE(4x4pirate @ 8 Nov, 2008 - 02:19 PM) *
How do I set the minimum on DateTimeCheckOutPicker.MinDate = dtmSystemDate (PLUS ONE DAY)


try dtmSystemDate.adddays(int)

User is offlineProfile CardPM
+Quote Post

4x4pirate
RE: Datepicker - If Statements
8 Nov, 2008 - 03:12 PM
Post #8

D.I.C Head
**

Joined: 18 Oct, 2006
Posts: 52


My Contributions
QUOTE(Pwn @ 8 Nov, 2008 - 03:05 PM) *

QUOTE(4x4pirate @ 8 Nov, 2008 - 02:19 PM) *
How do I set the minimum on DateTimeCheckOutPicker.MinDate = dtmSystemDate (PLUS ONE DAY)


try dtmSystemDate.adddays(int)


thanks!!
User is offlineProfile CardPM
+Quote Post

4x4pirate
RE: Datepicker - If Statements
8 Nov, 2008 - 03:25 PM
Post #9

D.I.C Head
**

Joined: 18 Oct, 2006
Posts: 52


My Contributions
nope.. didnt work.. throws an unhandled exception.. sad.gif
User is offlineProfile CardPM
+Quote Post

dbasnett
RE: Datepicker - If Statements
9 Nov, 2008 - 03:49 PM
Post #10

D.I.C Head
**

Joined: 1 Oct, 2008
Posts: 224



Thanked: 13 times
My Contributions
DateTimePicker1.MinDate = DateAdd(DateInterval.Day, 1, DateTime.Now)

User is offlineProfile CardPM
+Quote Post

4x4pirate
RE: Datepicker - If Statements
9 Nov, 2008 - 06:09 PM
Post #11

D.I.C Head
**

Joined: 18 Oct, 2006
Posts: 52


My Contributions
QUOTE(dbasnett @ 9 Nov, 2008 - 03:49 PM) *

DateTimePicker1.MinDate = DateAdd(DateInterval.Day, 1, DateTime.Now)



Solved.. thanks for the help!!
User is offlineProfile CardPM
+Quote Post

justAgal
RE: Datepicker - If Statements
12 Nov, 2008 - 08:53 PM
Post #12

New D.I.C Head
*

Joined: 24 Sep, 2008
Posts: 15


My Contributions
Wait a minute....was that message "Dumbass"? Hope this wasn't an assignment blink.gif




QUOTE(4x4pirate @ 9 Nov, 2008 - 06:09 PM) *

QUOTE(dbasnett @ 9 Nov, 2008 - 03:49 PM) *

DateTimePicker1.MinDate = DateAdd(DateInterval.Day, 1, DateTime.Now)



Solved.. thanks for the help!!


User is offlineProfile CardPM
+Quote Post

Pwn
RE: Datepicker - If Statements
14 Nov, 2008 - 01:28 PM
Post #13

D.I.C Regular
***

Joined: 25 Nov, 2007
Posts: 319



Thanked: 12 times
My Contributions
no, it was dubmass, so he's fine
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 02:52PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month