Information générale
Catégorie:
Gestionnaire d'écran & Écrans
>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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement