-
I'm a VB beginner.
In an exercise we wrote a little program that returns the difference of a given date to the date the program is run (e.g. "still 28 days left")
We're on a German Workstation and used the German date format, so the line was like this:
(You have to press a button called lblAbschied.)
lbl.Abschied.caption = "still " & DateDiff("d", Now, "16.06.2000") & " days left"
As you see, in the DateDiff the format for the end date is the German date format dd.mm.yyyy
When I run this on an English system it returns an error (runs fine on a German system)
My question is:
Is there either
a common date format (like dd/mm/yy) that would work in any language setting
or
a possibility to set the date format for a program
so it'll work on any language.
Thank you for any help!
Jens ;-)
-
Well, I know that if you have Windows Script Host installed there is a handy little function called GetLocale that returns a string representing your current locale.
There is even another function for SetLocale. If you set the locale right before you pull the date, you can be sure that it is returning the date in the correct format (Just be sure to store the current locale in a variable to set it back when you're finished).
For more information on this function goto:
http://msdn.microsoft.com/scripting/
and you can download a help file that tells you all the possible returned values.
-
Hello!
Thank you very much for your reply and the suggested download. I got the help file and will read through it.
But I was wondering if there isn't some simple declaration of the date format where I don't have to change the locale settings or do an if/else string to set the format according to the user's settings...
I'm using VBScript with ASP on my webserver and I know how to set the date format there:
I simply add the line <const LDIC_US = 1033> at the top of my ASP page and this tells the server which date format to use (here the US format m/d/yyyy)
So I imagined there'd be some easy way to set the date format for VisualBasic code as well...
Jens