|
-
Mar 10th, 2011, 09:34 PM
#1
Thread Starter
Junior Member
DateTimePicker Format help
Hello,
I need to have my date into a label.text = 03/10/2011
I'm able to do that on my datetimepicker1 but when I try to pass to the text it brings in short date = 3/10/2011
I need the zeros.
Code:
'format the datetimepicker value
Me.DateTimePicker1.CustomFormat = "MM/dd/yyyy"
Me.DateTimePicker1.Format = DateTimePickerFormat.Custom
Me.Label1.Text = Me.DateTimePicker1.Value.ToShortDateString
How can I have the value of label1.text with 03/10/2011 and not 3/10/2011?
thanks,
Kerb
-
Mar 10th, 2011, 10:02 PM
#2
Re: DateTimePicker Format help
ToShortDateString uses the system short date format, so it's nothing to do with your DTP. If you want the same text as is in the DTP then just use the Text property of the DTP. Otherwise, call ToString and pass a custom format string instead of calling ToShortDateString.
-
Mar 10th, 2011, 10:07 PM
#3
Thread Starter
Junior Member
Re: DateTimePicker Format help
Thanks JMCilhinney,
that was it,
Me.Label1.Text = Me.DateTimePicker1.Value.ToString("MM/dd/yyyy")
thanks,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|