ajeesh_ed ajeesh_ed - 1 year ago 84
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download