I have a textbox for date display which shows the date in this format: 17/04/2012 but I would like to format it to shows up like \'April 17, 2012\'. I tried this code
<
there have been couple of posts on this. Culprit seems to be your system date format. Use of short, medium, long formats will change the result when the system settings change.
Format$(yourdate, “dd/mm/yyyy”)
Format$(yourdate, “short date”)
If we look at explicitly defining your format, you are formulating your regional settings!
Good e.g. short date won’t always be mm/dd/yyyy but could be dd/mm/yyyy. That’s the key advantage over actually specifying the format. Simply you can change how you want your date to look like instead of depending on the system (with or without your knowledge).
When we first encountered this, we had some making the VBA apps and sending it over to another in some other place where they have own localized system date format. Your phone rings... ;)
In your case you could use,
UserForm1.txtDate.Value = Format$(Date,"mmmm dd, yyyy")
Or to be super-safe,
Dim dtDate as Date
dtDate = DateSerial(Year(Date), Month(Date), Day(Date))
UserForm1.txtDate.Value = Format$(dtDate, "mmmm dd, yyyy")
Hope that helps.