Results 1 to 5 of 5

Thread: Selected date to W/C

  1. #1

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Selected date to W/C

    Folks,

    I have some DateTimePicker controls. When the user selects a date, I would like to show the Week Commencing date, ie - the monday of the week selected.

    Any starters ?
    Bob

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Selected date to W/C

    VB Code:
    1. Dim chosenDate As Date = Me.DateTimePicker1.Value
    2.         Dim newDate As Date
    3.         Dim dayDifference As Double
    4.  
    5.  
    6.  
    7.  
    8.  
    9.  
    10.         dayDifference = Double.Parse((chosenDate.DayOfWeek - DayOfWeek.Monday).ToString)
    11.             newDate = DateAdd(DateInterval.Day, -dayDifference, chosenDate)
    12.             MessageBox.Show(newDate.ToLongDateString)

  3. #3

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Re: Selected date to W/C

    Thanks Mendhak, much appreciated.

    Also, Any idea how I can set the default DTP display to nothing rather than the current date ?

    Bob
    Last edited by staticbob; Mar 18th, 2005 at 04:54 AM.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Selected date to W/C

    Quote Originally Posted by staticbob
    Thanks Mendhak, much appreciated.

    Also, Any idea how I can set the default DTP display to nothing rather than the current date ?

    Bob
    YW...
    No clue about the next question though, sorry.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Selected date to W/C

    In order to assign a Nothing value to a dtp you need to set the .ShowCheckBox property to True and set the .Checked property to False.
    This is the only way to "display" a Null date value.

    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         DateTimePicker1.ShowCheckBox = True
    3.         DateTimePicker1.Checked = False
    4.     End Sub
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width