Hello Angelina
dtp1 and dpt in the code below are datetimepickers. Hope this helps
Ibrahim Malluf
Private Sub dtp2_ValueChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles dtp2.ValueChanged
Dim MyDays As Int32
Dim Date2 As DateTimePicker = DirectCast(sender, DateTimePicker)
MyDays = DateDiff(DateInterval.Day, dtp1.Value, Date2.Value)
If MyDays < 1 Then Date2.Value = DateAdd(DateInterval.Day, 1, Date2.Value)
Me.txtDays.Text = MyDays
End Sub
Private Sub dtp1_ValueChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles dtp1.ValueChanged
Dim MyDays As Int32
Dim Date1 As DateTimePicker = DirectCast(sender, DateTimePicker)
MyDays = DateDiff(DateInterval.Day, Date1.Value, dtp2.Value)
If MyDays < 1 Then
dtp2.Value = DateAdd(DateInterval.Day, 1, dtp2.Value)
MyDays = DateDiff(DateInterval.Day, Date1.Value, dtp2.Value)
End If
Me.txtDays.Text = MyDays
End Sub
"Angelina" <an*******@discussions.microsoft.com> wrote in message
news:06****************************@phx.gbl...
Hi,
I have got two DateTimePicker's on my form to accept a
guest arrival date and departure date.what i want to
acheieve is ensure that the DateTimePicker2 (departure)
is always greater than DateTimePicker1 (arrival date).
can anyone help me on the code for this? as u can tell,
im new learner.
i also want the days between the arrival date and
deparure date to be displayed in a 'length of stay
textbox'. i.e 2 nights stay.
or i want it so if they select a arrival date and enter 3
nights stay in the 'length of stay textbox' to adjust the
departure date automatically. Is this possible. can any
one help me on this coding or point me in the right
direction for any useful reasources.
Thx