Solved

vb.net DatePicker default to beginning and end of week

Posted on 2009-05-08
3
475 Views
Last Modified: 2012-05-06
I had created a VB.Net windows form.  I would like to use 2 datepicker as a search.  However, I would like the default value from first datepicker to be beginning date of week and datepicker2 to be ending date of week.

So example would be something like:
Monday - Sunday  -->  5/4/2009 - 5/10/2009
Monday - Sunday  -->  5/11/2009 - 5/17/2009
etc.

Can anyone help with this by sending my form_load to have these default date range for the datepicker control?
0
Comment
Question by:holemania
3 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 24339988
0
 
LVL 3

Accepted Solution

by:
xbrady earned 500 total points
ID: 24340050
dateTimePickerFirstDayOfWeek.Value = DateTime.Now.AddDays(-1 * CInt(DateTime.Now.DayOfWeek))
dateTimePickerLastDayOfWeek.Value = DateTime.Now.AddDays(6 - CInt(DateTime.Now.DayOfWeek))
0
 

Author Closing Comment

by:holemania
ID: 31579633
Awesome.  That's what I wanted
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Close form "before" open 3 43
Import a txt file into a DataGridView and TextBox 20 40
VB.Net - MemoryMappedFiles - Confirm receipt 2 20
vb.net winforms sizing/resolution? 4 34
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question