Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

VB6 - Date format

Original Message
Name: Sci-Guy
Date: February 8, 2005 at 21:37:00 Pacific
Subject: VB6 - Date format
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.


Report Offensive Message For Removal


Response Number 1
Name: Sci-Guy
Date: February 8, 2005 at 23:19:51 Pacific
Subject: VB6 - Date format
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 2
Name: StuartS
Date: February 9, 2005 at 08:58:16 Pacific
Subject: VB6 - Date format
Reply: (edit)
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


Report Offensive Follow Up For Removal

Response Number 3
Name: Sci-Guy
Date: February 10, 2005 at 02:05:03 Pacific
Subject: VB6 - Date format
Reply: (edit)
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.


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: VB6 - Date format

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




My PC has been hijacked!

Lexmark 2600 Printer Issues

btk1w1 infected start here post

Unwanted message remians on screen

Slow boot time


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC