View Full Version : txtDate
Ronmac
11-04-2009, 03:53 PM
Hi all,
Sorry - I've searched for the answer to this, but can't find it in this forum or on the net generally.
Does "txtDate = Date" return the format set in Control Panel/Regional Settings? If not, how would I change dates entered in a userform from US format to UK format?
I'd appreciate any advice.
Many thanks,
Ronmac
Ronmac
11-04-2009, 04:02 PM
I guess I've answered my own question - I've just checked my regional settings and they are already set to UK format. Short date is set to 04/11/09 and Long date to 04 November 2009 - however, any date input is appearing in US format.
I wondered if "txtDate = Date" required an addition such as "Date=UK" or some such code.
Regards,
Ronmac
Ronmac
11-04-2009, 05:16 PM
Hi,
I've found the answer through trial and error.
I needed to add the following to my code:
Dim LDate as Long
LDate = Date
then, instead of "txtDate = Date" I changed it to "txtDate = LDate". It now returns the date format from my system.
Cheers,
Ronmac
Is this in a TextBox on a UserForm?
Ronmac
11-05-2009, 01:07 AM
Hi GTO,
Yes, it is.
I sent a further msg stating that (having omitted it from my previous email) but it doesn't seem to have made it to the forum! I really must engage my brain.
Regards,
Ron
Dim LDate as Long
LDate = Date
then, instead of "txtDate = Date" I changed it to "txtDate = LDate". It now returns the date format from my system.
Greetings,
I must have been posting slow, as I had not seen your post at #4 when I asked. If it is solved, that is great:)
In case not, I would think that returning a Long to the text box would get something like 40122 in the textbox? I am probably staring straight at what I'm missing...
Anyways, I was just going to suggest something like
Private Sub UserForm_Initialize()
Dim lDate As Long
lDate = Date
Me.TextBox1.Value = lDate
Me.TextBox2.Value = Format(Date, "dd/mm/yyyy")
End Sub
Have a great day,
Mark
Ronmac
11-05-2009, 01:40 AM
Hi Mark,
Yes, I've solved it, but many thanks for taking the trouble to look at the problem. I've replied to your answer to my other question, too, which worked perfectly.
When the macro was run, txtDate = Date placed "11/04/09" in the appropriate textbox on my userform. Because that could be interpreted as 11th April 2009 (and not 4th November 2009 when the data was actually input) I needed the box to show (and insert) the UK format date.
By simply changing the code as I've said, it did both.
Again, many thanks for your trouble.
Kind regards,
Ron
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.