Date Format in a Userform Listbox

D

Deke

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.
 
J

Joel

Send it to the textbox as a string!

Deke said:
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.
 
A

Alan

Another way:

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

Regards,

Alan
 
S

Simon Lloyd

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top