JuanRodriguez
Fri Jul 22 08:21:02 CDT 2005
Roland
Thanks for your interesting reply. I will certainly will take your
suggestions into consideration.
I have actually found out what the problem was with my code in German
windows. Basically, the test function translates the value that returns to
the language of the version of windows and it was returning "Wahr" instead of
"True". This meant that I missed the value completely.
Thanks for you help.
Juan
"Roland Hall" wrote:
> "Juan Rodriguez" wrote in message
> news:25FA9AC2-972E-43B6-B55D-19B3474C5647@microsoft.com...
> : I have an international vbs application and I am using regular expressions
> : to validate the format of the dates entered by the user. It works fine
> when
> : running on a English windows PC but it does not recognised valid dates if
> the
> : PC has the German version of windows.
> :
> : This is the code I am using:
> :
> : Function FormatValRegExp(strValue, strRegExp)
> :
> : Dim re ' Regular Expression object
> : Dim response ' response
> :
> : On error resume next
> :
> : response = ""
> : Set re = new regexp ' Create the RegExp object
> : re.Pattern = strRegExp ' set pattern
> : re.IgnoreCase = true
> : response = re.test(strValue)
> : Set re = nothing
> :
> : FormatValRegExp = response
> :
> :
> : End Function
> :
> : This function wiht the following parameters:
> : strValue: 31.12.1996
> : strRegExp: \d{1,2}[.]\d{1,2}[.]\d{2,4}$
> : returns true in an English version of Windows and false in a German
> windows.
>
> You should consider using yyyy-mm-dd or yyyy/mm/dd or yyyy.mm.dd instead and
> this regexp:
> (19|20\d\d)[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])
>
> However, to use it with your dd.mm.yyyy format, you'd change it to:
> (0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.(19|20\d\d)
>
> but it will not accept d.m.yyyy. It must be dd.mm.yyyy
>
> You also need another test for leap year.
>
> I have a sample that mixes javacript and vbscript here:
>
http://kiddanger.com/lab/isdate2.html
>
> --
> Roland Hall
> /* This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose. */
> Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/
> WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
> MSDN Library -
http://msdn.microsoft.com/library/default.asp
>
>
>