Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to limit an EditBox to 3 CR/LF's
Message
 
À
09/09/1998 10:55:31
Brady Flax
Resource Consultants Inc.
Virginia Beach, Virginie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00134532
Message ID:
00134544
Vues:
13
Brady,

Try using the KeyPress event of the EditBox. If the user hits enter you'll get a 13 as the key code. You can then use NODEFAULT to keep the keystroke from being entered in the edit box. Like this:
IF nKeyCode=13 AND OCCURS(CHR(13),THIS.Value)>2
   NODEFAULT
ENDIF
>Greetings!
>
>I was wondering if anyone has run into this one in VFP 3.0...
>
>I am rying to limit the number of CR/LF's in an EditBox to a maximum of 3 so that the text entered will fit properly in an associated report.
>
>Since a the EditBox's ControlSource is a memo field, I have limited the EditBox's maximum number of characters(in this case 77); however, if a user decides to type a single character followed by a CR/LF, he or she could literally enter 77 lines, each with a single character...
>
>Here's what I've tried:
>
>In the InteractiveChange event of the EditBox I wrote the following code -
>
>IF OCCURS( CRLF, This.Value ) > 2
> -set focus to the next control on the form-
>ENDIF
>
>And in the GotFocus event I put -
>
>IF OCCURS( CRLF, This.Value ) > 2
> This.Value = STRTRAN( This.Value, CRLF, SPACE(1), 3 )
> This.Refresh
>ENDIF
>
>This way I would allow the user to reenter the control even though 3 CR/LF's might be in the EditBox's value.
>
>The EditBox behaves erratically, sometimes placing additional CR/LF's after pressing , sometimes losing focus after only 2 CR/LF's have been entered. ???
>
>I know this sounds trivial, but my employer is a stickler for minutiae (Gee, sounds familiar, huh? <grin>)
>
>Thanks for any suggestions you may have!
>
>-Brady
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform