Hi Finn,
I write a date in a textbox in a userform.
Eks: I want to write 1st august 2003. I write in the textbox 01-08-2003(this
is the format I want to use, and which is common used in Denmark). But one
computer understands it as 8. january 2003
Isnt this due to the international date format?
It's partly due to the international date format, but more to do with the way
your code is handling the text entered. As Harald pointed out, instead of
forcing specific formats on your users, it is better practice to respond to
their choice of format, as set in Control Panel, by explicitly converting
between a date number and the textual representation of it.
So given a date variable dtDateVar and a text box on a form tbDateBox, the
following VBA can be used to convert between them:
'Display a date according to the user's settings
tbDateBox.Text = Format$(dtDateVar, "Short Date")
'Interpret a date according to the user's settings
If IsDate(tbDateBox.Text) Then
dtDateVar = CDate(tbDateBox.Text)
End If
Regards
Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk