View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 1,327
Default How to change international decimal separator

Hi Finn

It's a question of how the date format is set in the control panel. If it's
dd-mm-yy then we assume that this is how the user enters and uses dates. If
it's mm-dd-yy then that's what we assume.

The trick is that a date is a date is a date, how it's entered and shown is
just a question of formatting. No matter how it's entered, we assume that
the control panel and the user agree. For this Datevalue is a great tool, it
handles all common date entries (1.8 , aug 1 03, 1/8-03, almost anything)
and harmonizes it with the control panel settings. Try something like

Private Sub CommandButton1_Click()
Dim D As Date
If IsDate(DateValue(TextBox1.Text)) Then
D = DateValue(TextBox1.Text)
MsgBox "You wrote " & _
Format(D, "dddd mmmm d. yyyy")
Else
TextBox1.Text = ""
MsgBox "No date"
End If
End Sub

and do NOT prompt for something like "enter dates in format dd-mm-yyyy" -let
Datevalue do her job. The error you mention is because the user is on
dd-mm-yy and the control panel setting is mm-dd-yy. Change the computer to
match the user.
--
HTH. Best wishes Harald
Followup to newsgroup only please

"Finn Petersen" skrev i melding
...
Hi Stephen
Maybe I am wrong.

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?

Finn