Re: datetimepicker question
- From: "Rick Rothstein \(MVP - VB\)" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Thu, 16 Nov 2006 11:59:15 -0500
I'm using a datetimepicker control, I want the user to pick a month/year
using the control. The actual day of the month they pick is of no value.
What I want to do is to get the first day of the month and the last day of
the month of the month they select.
Any idea of how I can grab these two dates?
First off, if you don't care about the actual day, why show the user a
monthly calendar display that requires him/her to select a day? Why not just
use a ComboBox for the months and, depending on the range of years allowed,
either a ComboBox or TextBox for inputting the year value?
Anyway, to answer your question, use the CloseUp event to reset the value
picked by the user to the one you want. Use either this...
' Set first day of month
With DTPicker1
.Value = DateSerial(.Year, .Month, 1)
End With
or this...
' Set last day of month
Private Sub DTPicker1_CloseUp()
With DTPicker1
.Value = DateSerial(.Year, .Month + 1, 0)
End With
depending on what you want your user to see.
Rick
.
- Prev by Date: Re: How to create WPF Custom routedevent in VB ?
- Next by Date: Re: EXE Crashes On MDI Window With VB6 OCX
- Previous by thread: How to create WPF Custom routedevent in VB ?
- Next by thread: Re: EXE Crashes On MDI Window With VB6 OCX
- Index(es):
Relevant Pages
|