Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Forcing 4 digit entry of the century part of a date
Message
De
14/09/1998 07:27:24
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
14/09/1998 06:35:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00136067
Message ID:
00136075
Vues:
19
>We have a situation where bonds are maturing in more than 100 years time. Hence we need to ensure that we can trap when a user enters a two digit century, and force the user to enter 4 digits. - Looks simple enough!
>
>Unfortunately it seems that VFP's SET CENTURY xx ROLLOVER nn functionality fires before the valid event of the text-box and therefore makes an assumption, which in this instance is invalid.
>
>
>Here's an example of the problem.
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> User has a bond which matures on 01/01/2109
>
> So he enters 01/01/19
>
> IF SET CENTURY xx ROLLOVER 50 is set on then VFP assumes
>
> 01/01/2019 - Incorrect!!!
>
> IF SET CENTURY xx ROLLOVER 50 is set off – (I.e. Rollover 0?) then VFP assumes
>
> 01/01/1919 - Incorrect!!!
>
> Unfortunatley with users being who/what they are, it is likely
> that the user will make an assumption that the system has
> interpreted his entry correctly - no bothering to check.
>
>I've looked at the various text-box properties in VFP 5.0 and nothing (includes StrictDateEntry, DateFormat and Century) seems to give me the control I need. - I cannot believe that no-one else has encountered this problem?!?
>
>Does VFP 6.0 have better control over date entry?
>
>Anybody have any ideas?
>
>Many Regards,
>
>James.
James,
Cumbersome but this one works. Check textbox.text (unformatted as user entered) and change value as needed ie:
*valid
lnDesiredCentury = 21
lnYearDigits = len(alltrim(substr(this.text,7)))
if lnYearDigits < 4
	this.value = ctod(stuff(this.text,7,0,;
           substr(str(lnDesiredCentury*100,4),1,;
           4-lnYearDigits)))
endif
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform