Set two DateTimePicker date range to current year - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This code is used when you need to set two DateTimePicker date value to the range of the beginning of the current year and the current day. Example: you make a software to track a store sales and you want to know how much in sales you made so far this year.

In this program, you will learn how to change the value of the two DateTimePicker control: the first one to the beginning of this year and the second one to the current day.

DateTimePicker1.Value = Today.Date.AddMonths(-Today.Month + 1)
DateTimePicker1.Value = DateTimePicker1.Value.Date.AddDays(-Today.Day + 1)
DateTimePicker2.Value = Today.Date

vb.net last year


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.