ajeesh_ed ajeesh_ed - 6 months ago 4x
Vb.net Question

How to set the default value in datetimepicker as previous month

I have my VB.net program with a

and the custom format of which is
. I want the default value at application startup in the
as previous month and I don't care whatever day it shows(it can be any day of previous month of the same year). Using
DateTimePicker.Value = CDate(Now.Date.AddDays(-(Now.Day)))
give me the value I want but how can I set it as the default value at application startup?


I got the answer working fine. adding the following code to form load event served my purpose

Dim dt = DateTime.Now.AddMonths(-1) 
me.DateTimePicker.Value = dt

Thanks plutonix for your help.