Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: Sci-Guy
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.

I found that it works on all machines if I don't format the date at all.
E.G.
TmpCRD = NowIs this considered acceptable?
Please let us know if you found someone's advice to be helpful.

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

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.

![]() |
![]() |
![]() |

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