Whenever I don't like the way the Format functions are working, I pull
everthing apart and then put it back together EXACTLY the way I want it to be.
In your case I would use this:
Dim Month as Integer
Dim Year as Integer
Dim Day as Integer
Dim TheFinalProduct as String
Month = VBA.Month(Calendar1.Value)
Year = VBA.Year(Calendar1.Value)
Day = VBA.Day(Calendar1.Value)
TheFinalProduct = Day & "/" & Month & "/" & Year
TextBox2 = TheFinalProduct
Try It, this comes in handy for me all the time.
"s_ali_hassan" wrote:
>
> i have a calendar from which a user selects the date, which is then
> displayed in a text box. The problem is that the date displayed in the
> textbox is in the format mm/dd/yyyy, when i want it to be dd/mm/yyyy.
> ive tried a few things but cannot get it to display the date correctly,
> here is my code:
>
> Private Sub Calendar1_Click()
> TextBox2 = Calendar1.Value
> TextBox2 = Format(TextBox2, "dd/mm/yyyy")
>
> End Sub
>
> my regional setting is set to english (UK).
> the properties on the calendar shows the values on the calendar as
> dd/mm/yyyy. But when i run the macro, the text box shows it
> differently.
> Also after trying to convert the format in the text box, it half works,
>
> by this i mean if i select the 24 of june 2006, it displays it as
> 24/06/2006, which is cool, but if i select 8th of june 2006, then it
> displays it as 6/8/2006, which is messed up.
>
> how can i get this to work??
> any ideas?
>
> pls help if u can
>
> thanks
>
>
> --
> s_ali_hassan
> ------------------------------------------------------------------------
> s_ali_hassan's Profile: http://www.excelforum.com/member.php...o&userid=35325
> View this thread: http://www.excelforum.com/showthread...hreadid=557248
>
>
Bookmarks