Computing.Net > Forums > Programming > VB6 - Date format

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VB6 - Date format

Reply to Message Icon

Name: Sci-Guy
Date: February 8, 2005 at 21:37:00 Pacific
OS: XP Pro SP1
CPU/Ram: Athlon XP 2600+ / 1024Mb
Comment:

I'm trying to use a variation of the code on this page:

http://www.2poto.com/vbwebboard/00009.html

I'm finding that on one of my XP machines, the code on that website works well. But on another two XP machines, it won't work unless I change the format of the date.

E.G.
TmpCRD = Format(Now, "m/d/yy")
has to be changed to:
TmpCRD = Format(Now, "d/m/yy")

How can I ensure that the date format will work regardless of which machine it's used on?

This is only a learning exercise, but it seems strange that this is occurring. There must be a remedy for this. Can someone give me a shove in the right direction?


Please let us know if you found someone's advice to be helpful.



Sponsored Link
Ads by Google

Response Number 1
Name: Sci-Guy
Date: February 8, 2005 at 23:19:51 Pacific
Reply:

I found that it works on all machines if I don't format the date at all.

E.G.
TmpCRD = Now

Is this considered acceptable?


Please let us know if you found someone's advice to be helpful.


0

Response Number 2
Name: StuartS
Date: February 9, 2005 at 08:58:16 Pacific
Reply:

Use the date format that is set in the Regional Options of control panel.

TmpCRD = Format(Now, "short date")

of

TmpCRD = Format(Now, "long date")

This will ensure that your application works whatever the date format of the country it is running in.

Be aware though that if the date format is set as dd MMM yyyy which will give you 09 Feb 2005 can cause problems with some applications which insist on the date format being all numerical like dd/MM/yyyy which will give you 09/02/2005.

Now will give you the date in the correct format, but will also give you the time which may not be what you want.

Stuart


0

Response Number 3
Name: Sci-Guy
Date: February 10, 2005 at 02:05:03 Pacific
Reply:

Thanks for the reply Stuart. I ended up using:

TmpCRD = DateValue(Now)

This works on all my machines regardless of regional settings and doesn't include the time.

I also figured out how to ensure that DateGood()=False if anyone changed the FRD registry entry. I did that with an encrypted ini file kept in the system directory. With this addition, this code is just that little more secure.


Please let us know if you found someone's advice to be helpful.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB6 - Date format

About short date format www.computing.net/answers/programming/about-short-date-format/14137.html

How can I get the Date format I wan www.computing.net/answers/programming/how-can-i-get-the-date-format-i-wan/3131.html

Using batch to change date format www.computing.net/answers/programming/using-batch-to-change-date-format/16172.html