Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to stop when the field length is reached
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00676137
Message ID:
00676174
Vues:
19
>>>>>Hi evrybody,
>>>>>
>>>>>When the user enters data into the field, if the maximum length of the field is riched, the entering is continuing in the next field. How can I prevent it, e.g. when the maximum length is riched, the cursor stays in the field and no more keystrokes are accepted?
>>>>>
>>>>>Thanks in advance.
>>>>
>>>>
>>>>SET CONFIRM ON
>>>>
>>>>
>>>>HTH
>>>
>>>It doesn't fire Valid and LostFocus when the last symbol is typed, so I can not use it.
>>
>>So you need to fire one of this events and stay in the control?
>>Then the suggestion with condition check on the interactivechage event is appropriate to your situation.
>>
>>Kind Regards
>
>If doesn't seem to work. For instance, I have a textbox with controlsource BldMstr.Page (it's an integer field). I set MaxLength to 2 (for testing sake), but it still allows me to type 7 digits.
>
>I tried the following code in textbox InteractiveChange:
>
>if len(alltrim(this.text))>this.MaxLength
>   nodefault
>endif
>
>But it doesn't work either.
>
>What else can I do? May be set confirm ON in interactive change? (Back to off in GotFocus)?

This code in KeyPress seems to fix the problem:
LPARAMETERS nKeyCode, nShiftAltCtrl
if (between(m.nKeyCode,48,57) or between(m.nKeyCode,65,122)) ; && Letter or digit
   and len(alltrim(this.text))>=this.MaxLength
   nodefault
endif
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform