datepicker - If Statements

Prevent a date from being picked less than current date?

Page 1 of 1

12 Replies - 6247 Views - Last Post: 14 November 2008 - 02:28 PM Rate Topic: -----

#1 4x4pirate   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 18-October 06

datepicker - If Statements

Post icon  Posted 08 November 2008 - 10:56 AM

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)



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 


Is This A Good Question/Topic? 0
  • +

Replies To: datepicker - If Statements

#2 4x4pirate   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 18-October 06

Re: datepicker - If Statements

Posted 08 November 2008 - 12:20 PM

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?
Was This Post Helpful? 0
  • +
  • -

#3 Pwn   User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 458
  • Joined: 25-November 07

Re: datepicker - If Statements

Posted 08 November 2008 - 02: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.

This post has been edited by Pwn: 08 November 2008 - 02:09 PM

Was This Post Helpful? 0
  • +
  • -

#4 4x4pirate   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 18-October 06

Re: datepicker - If Statements

Posted 08 November 2008 - 02:48 PM

View PostPwn, on 8 Nov, 2008 - 01:07 PM, said:

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
Was This Post Helpful? 0
  • +
  • -

#5 4x4pirate   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 18-October 06

Re: datepicker - If Statements

Posted 08 November 2008 - 03:05 PM

Got it.. :)

DateTimeCheckInPicker.MinDate = dtmSystemDate
DateIN = DateTimeCheckInPicker.Value
If DateIN > dtmSystemDate Then
MessageBox.Show("Dubmass")
Was This Post Helpful? 0
  • +
  • -

#6 4x4pirate   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 18-October 06

Re: datepicker - If Statements

Posted 08 November 2008 - 03:19 PM

View Post4x4pirate, on 8 Nov, 2008 - 02:05 PM, said:

Got it.. :)

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)
Was This Post Helpful? 0
  • +
  • -

#7 Pwn   User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 458
  • Joined: 25-November 07

Re: datepicker - If Statements

Posted 08 November 2008 - 04:05 PM

View Post4x4pirate, on 8 Nov, 2008 - 02:19 PM, said:

How do I set the minimum on DateTimeCheckOutPicker.MinDate = dtmSystemDate (PLUS ONE DAY)


try dtmSystemDate.adddays(int)
Was This Post Helpful? 0
  • +
  • -

#8 4x4pirate   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 18-October 06

Re: datepicker - If Statements

Posted 08 November 2008 - 04:12 PM

View PostPwn, on 8 Nov, 2008 - 03:05 PM, said:

View Post4x4pirate, on 8 Nov, 2008 - 02:19 PM, said:

How do I set the minimum on DateTimeCheckOutPicker.MinDate = dtmSystemDate (PLUS ONE DAY)


try dtmSystemDate.adddays(int)


thanks!!
Was This Post Helpful? 0
  • +
  • -

#9 4x4pirate   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 18-October 06

Re: datepicker - If Statements

Posted 08 November 2008 - 04:25 PM

nope.. didnt work.. throws an unhandled exception.. :(
Was This Post Helpful? 0
  • +
  • -

#10 dbasnett   User is offline

  • D.I.C Addict
  • member icon

Reputation: 121
  • View blog
  • Posts: 666
  • Joined: 01-October 08

Re: datepicker - If Statements

Posted 09 November 2008 - 04:49 PM

DateTimePicker1.MinDate = DateAdd(DateInterval.Day, 1, DateTime.Now)
Was This Post Helpful? 0
  • +
  • -

#11 4x4pirate   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 18-October 06

Re: datepicker - If Statements

Posted 09 November 2008 - 07:09 PM

View Postdbasnett, on 9 Nov, 2008 - 03:49 PM, said:

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



Solved.. thanks for the help!!
Was This Post Helpful? 0
  • +
  • -

#12 justAgal   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 24-September 08

Re: datepicker - If Statements

Posted 12 November 2008 - 09:53 PM

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




View Post4x4pirate, on 9 Nov, 2008 - 06:09 PM, said:

View Postdbasnett, on 9 Nov, 2008 - 03:49 PM, said:

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



Solved.. thanks for the help!!

Was This Post Helpful? 0
  • +
  • -

#13 Pwn   User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 458
  • Joined: 25-November 07

Re: datepicker - If Statements

Posted 14 November 2008 - 02:28 PM

no, it was dubmass, so he's fine
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1