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:
00067471
Vues:
24
>Thanks, I've changed the code as follows:
>
>IF len(alltrim(wires.CUtransit))<>8
>=messagebox("Transit Number must be 8 characters [ie. 12347879] !",16,oCUWS.appname)
>return 0
>else
> if right(wires.CUtransit,4)<>"7879"
> =messagebox("Transit Number must end with '7879' !",16,oCUWS.appname)
> return 0
> endif
>endif
>
>My problem now is that the user can't do anything unless the field has 8 characters and the last four characters are "7879". I want the user to have the ability to cancel the transaction without having this field correctly filled in. What do I have to change to make this possible.

I still don't understand why you show a message when the string doesn't end with "7879". You could have a 4 char entry field and "fix" the string in the valid code by adding the "7879" suffix.

Jim Booth gave the solution for your problem: You should have a cancel button on the form with the Cancel property set to .T. and at the begging of your validation method:

IF LASTKEY() = 27 && Escape
RETURN .T.
ENDIF

This will allow the user to press Escape to cancel or... and this is the nice part, click on the Cancel button.

BTW, when returning from a validation/when procedure, you can use RETURN .T. or RETURN .F. instead of RETURN 1/RETURN 0. Although it works, these methods are supposed to return a logical and not a numerical value. The code becomes more clear this way.

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

Click here to load this message in the networking platform