DateTimePicker

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to know the number of days.
Here is my code:
Dim dt1 = DateTimePicker1.Value()
Dim dt2 = DateTimePicker2.Value()
TextBox1.Text + CStr(dt2.Subtract(dt1).Days)
TextBox1.Refresh
I have all the code in a Timer1.Tick event. The code works fine, but is
there other way to do this, so if someone changes the date it will show how
many days in real-time
 
freddy said:
I want to know the number of days.
Here is my code:
Dim dt1 = DateTimePicker1.Value()
Dim dt2 = DateTimePicker2.Value()
TextBox1.Text + CStr(dt2.Subtract(dt1).Days)
TextBox1.Refresh
I have all the code in a Timer1.Tick event. The code works fine, but is
there other way to do this, so if someone changes the date it will show
how
many days in real-time

Add a handler to the datetimepicker's 'ValueChanged' event and perform the
calculation there.
 
Freddy,

You mean something as this,

\\\
Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged, _
DateTimePicker1.ValueChanged
Dim dt1 As DateTime = DateTimePicker1.Value()
Dim dt2 As DateTime = DateTimePicker2.Value()
TextBox1.Text = (dt2.Date.Subtract(dt1.Date).Days).ToString
End Sub
///

I hope this helps,

Cor
 
Back
Top