user2086396 user2086396 - 23 days ago 6
Vb.net Question

Get the specific text

I have to get the days between a specific date entered by the user, and the current date in a text box.

So, the simplest code as I think will be as follows:

Private Sub DateTimePicker1_ValueChanged(sender As System.Object, e As System.EventArgs) Handles DateTimePicker1.ValueChanged
TextBox1.Text = (DateTimePicker1.Value - Today).ToString


Now, suppose the user selects the date to be
02 March 2013
, then the result of this is like
11.12:48:21
but I just want the data to be like 11 i.e without the time.

I tried changing it to
Value.Day
and
Value.DayOfYear
, but it does not give the desired output.

I just want to calculate the number of days between today, and the user selected date in a dd or ddd or dddd manner.

Can someone guide me in the right way?

Answer

I solved it using this:

TextBox1.Text = (DateTimePicker1.Value.Date - Today.Date).Days

Just one word made so much difference.