Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Validating a textbox field
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00067407
Message ID:
00067412
Vues:
29
>I have a form in which I test for two items in a certain field:
>
>1. That the user has keyed in 8 characters
>
>2. That the last four characters are "7879"
>
>This is the code in the valid method of the textbox:
>
>** start - Valid method of textbox **
>
>al = len(wires.CUtransit) && create memory variable to
>save to zzz all like al && see what VFP says is the length of expression
>

You must test here LEN(ALLTRIM(this.value)) as David Moore already said.

>IF len(this.value)<>8
>=messagebox("Transit Number must be 8 characters [ie. 12347879] !",16,oCUWS.appname)
>else

You don't need to test the length here. It has to be 8 because you're on the ELSE of <> 8.

> if right(this.value,4)<>"7879" and len(this.value) = 8

Why showing a message? If you already know that the last chars must be "7879", you can fix the value if it's wrong. Why force the user to type "7879" each time?

> =messagebox("Transit Number must end with '7879' !",16,oCUWS.appname)
> endif
>endif

Vlad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform