PDA

View Full Version : [SOLVED] Date format in userform text box



gibbo1715
08-29-2005, 04:49 AM
can anyone tell me how to format my text box so my users can view a date in uk style and not us style?

Also need to save the date from a text box into a spreadsheet in the correct format so will also need to change the format prior to the save

cheers

gibbo

Bob Phillips
08-29-2005, 04:58 AM
can anyone tell me how to format my text box so my users can view a date in uk style and not us style?

Also need to save the date from a text box into a spreadsheet in the correct format so will also need to change the format prior to the save

cheers

gibbo

You can have any format in a textbox, doesn't have to be US style, so I don't get the first question.

Second, cast it
CDate(Textbox1.Text)

gibbo1715
08-29-2005, 05:09 AM
sorry for my poor explanation, i have data on my spreadsheet that is formatted to uk style, when i call that data into my form (frm1.Textbox1.value = ActiveCell.Value) it is displayed as US Style i.e. in my cell 01/08/2005 where as on my userform it shows as 08/01/2005

Bob Phillips
08-29-2005, 05:13 AM
sorry for my poor explanation, i have data on my spreadsheet that is formatted to uk style, when i call that data into my form (frm1.Textbox1.value = ActiveCell.Value) it is displayed as US Style i.e. in my cell 01/08/2005 where as on my userform it shows as 08/01/2005

Okay, so just force it


Textbox1.Text = Format(Range("A1").Value, "dd/mm/yyyy")
.

gibbo1715
08-29-2005, 05:35 AM
That worked great for displaying the data in a text box so my text box now displays dd/mm/yyyy as required, but doesnt work for saving the data to the spreadsheet

How do I code the value in the text box so that when i save it i get dd/mm/yyyy format on my spreadsheet and not mm/dd/yyyy ?

dont quite understand the CDate(Textbox1.Text)command can u explain this for me

cheers

gibbo?

Bob Phillips
08-29-2005, 05:42 AM
How do I code the value in the text box so that when i save it i get dd/mm/yyyy format on my spreadsheet and not mm/dd/yyyy ?

dont quite understand the CDate(Textbox1.Text)command can u explain this for me


Range("B1").Value = CDate(TextBox1.Text)

.

gibbo1715
08-29-2005, 05:47 AM
Thanks for taking the time to explain that to me, certainly something i will be using in the future

thankyou

Gibbo