all groups > vb.net controls > november 2005 >
You're in the

vb.net controls

group:

calendar control format date.


calendar control format date. brian.sheahan NO[at]SPAM gmail.com
11/4/2005 1:51:41 PM
vb.net controls:
i need to format a date to look like dd/mm/yyyy when i click on the
calendarcontrol.selectionChanged() argument. this is my code:

Sub calDateUpdated_SelectionChanged(ByVal Sender As System.Object,
ByVal e As System.EventArgs) Handles calDateUpdated.SelectionChanged
'Populate the lblDateUpdated Control in the form with the
desired date.
lblDateUpdated.Text = calDateUpdated.SelectedDate
End Sub

basically, when i select a date, a label control is set to it's date.
but i want it to read in this format, for example, for the date of
january 1st, 2005:

01/01/2005

but right now, it reads it like this:

1/1/2005

It's important to get the 0's in there. please help. thanks.

brian
Re: calendar control format date. Claes Bergefall
11/7/2005 10:43:51 AM
lblDateUpdated.Text = calDateUpdated.SelectedDate.ToString("dd\/MM\/yyyy")
Check out DateTimeFormatInfo for more info on formating strings

/claes

[quoted text, click to view]

AddThis Social Bookmark Button