Welcome to Dream.In.Code
Click Here
Getting VB.NET Help is Easy!

Join 117,523 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 2,041 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



DateTimePicker date selection

 
Reply to this topicStart new topic

DateTimePicker date selection

spazband
post 3 Jul, 2008 - 07:22 AM
Post #1


New D.I.C Head

*
Joined: 3 Jul, 2008
Posts: 4


My Contributions


I am using a DateTime Picker to select a date that will be used for building a report. I need to have the date default to Monday of the week the date was selected.

For Example: if the user selected Thursday - July 17, 2008, I want the control to default to and show Monday - July 14, 2008.

I am looking for help in changing the selected date to show the start date of the week for the selection.
User is offlineProfile CardPM

Go to the top of the page


bflosabre91
post 3 Jul, 2008 - 10:44 AM
Post #2


D.I.C Head

**
Joined: 22 Feb, 2008
Posts: 164


My Contributions


the way i would do this would be to use a case statement with the days of the week. if the day of the week was wednesday, it would take that date and subtract 2 days to get monday. just capture the day of the week and subtract however many days are needed.
User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 3 Jul, 2008 - 01:58 PM
Post #3


DICula

Group Icon
Joined: 29 May, 2008
Posts: 602



Thanked 38 times

Dream Kudos: 2000
My Contributions


QUOTE(bflosabre91 @ 3 Jul, 2008 - 06:44 PM) *

the way i would do this would be to use a case statement with the days of the week. if the day of the week was wednesday, it would take that date and subtract 2 days to get monday. just capture the day of the week and subtract however many days are needed.

Why do all that, when it can be do in a single line? ques.gif

This post has been edited by AdamSpeight2008: 3 Jul, 2008 - 02:00 PM
User is offlineProfile CardPM

Go to the top of the page

spazband
post 3 Jul, 2008 - 02:09 PM
Post #4


New D.I.C Head

*
Joined: 3 Jul, 2008
Posts: 4


My Contributions


QUOTE(bflosabre91 @ 3 Jul, 2008 - 10:44 AM) *

the way i would do this would be to use a case statement with the days of the week. if the day of the week was wednesday, it would take that date and subtract 2 days to get monday. just capture the day of the week and subtract however many days are needed.


And what would be the single line you are speaking of?
User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 3 Jul, 2008 - 02:23 PM
Post #5


DICula

Group Icon
Joined: 29 May, 2008
Posts: 602



Thanked 38 times

Dream Kudos: 2000
My Contributions


QUOTE(spazband @ 3 Jul, 2008 - 10:09 PM) *

And what would be the single line you are speaking of?

I can only give hints at the moment (See Rules) but examine, especially the intellisense descriptions, the extensions of the value property, as they contain a couple of things you'll need.
User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 5 Jul, 2008 - 12:13 PM
Post #6


DICula

Group Icon
Joined: 29 May, 2008
Posts: 602



Thanked 38 times

Dream Kudos: 2000
My Contributions


In the value changed event
vb

Static Protection As Boolean : If Not (Protection) Then Protection = True : DateTimePicker1.Value = DateTimePicker1.Value.AddDays(-7 + DayOfWeek.Monday - DateTimePicker1.Value.DayOfWeek) : Protection = False: End If

By changing the -7 to 0 (Zero) you can to Mon after.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 03:25PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month