ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date Format in a Userform Listbox (https://www.excelbanter.com/excel-programming/383651-date-format-userform-listbox.html)

Deke

Date Format in a Userform Listbox
 
I am having a bit of a problem with the format of dates in a userform
listbox. The dates going into the listbox is formatted as "dd/mm/yyyy" from
an array, but when the userform is displayed the date changes format to
"mm/dd/yyyy".

When the date is them passed back to a variable and then used for a search
it fails, obviously.

Hope someone can help.

--
Cheers...

joel

Date Format in a Userform Listbox
 
Send it to the textbox as a string!

"Deke" wrote:

Thanks for the reply. The date that is getting stored in the array, which is
then passed to the listbox, which is defined as a DATE type, so there is no
convertion to a string happening. All that seems to be happening is it's
getting changed from a UK date format, which is what I want, to a US date
format.

Hope this makes sense.
--
Cheers...


"Joel" wrote:

Is the date getting converted from a "date to string" or "string to date".
Excel time formats will always take any time (integer) because it is really
just an integer from the year 1900. Then the time is displayed in different
formats. If you are getting an errror then the time mustt of been converted
tto a string. You then havve to convert the string back to a time using =
datevalue(string) or in VBA datevalue(string) which will take any standard
date format.

"Deke" wrote:

I am having a bit of a problem with the format of dates in a userform
listbox. The dates going into the listbox is formatted as "dd/mm/yyyy" from
an array, but when the userform is displayed the date changes format to
"mm/dd/yyyy".

When the date is them passed back to a variable and then used for a search
it fails, obviously.

Hope someone can help.

--
Cheers...


Alan[_2_]

Date Format in a Userform Listbox
 
Another way:

Private Sub ControlButton1_Change()
ControlButton1 = Format(ControlButton1, "dd/mm/yyyy")
End Sub

Regards,

Alan


"Deke" wrote in message
...
I am having a bit of a problem with the format of dates in a userform
listbox. The dates going into the listbox is formatted as "dd/mm/yyyy"
from
an array, but when the userform is displayed the date changes format to
"mm/dd/yyyy".

When the date is them passed back to a variable and then used for a search
it fails, obviously.

Hope someone can help.

--
Cheers...




Simon Lloyd[_913_]

Date Format in a Userform Listbox
 

If this listbox is on a userform then you could use:

Code:
--------------------
userform1.ListBox1.Value = Format(Userform1.ListBox1.Value, "dd/mm/yyyy")
--------------------
in your userform initialize
or combobox change or which ever affects the userform during start up
or process of data.

Regards,
SImon


--
Simon Lloyd


All times are GMT +1. The time now is 12:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com