Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting trailing spaces in textbox control
Message
 
 
À
29/03/2001 21:25:48
Jill Derickson
Software Specialties
Saipan, CNMI
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00489758
Message ID:
00490173
Vues:
12
Hi Jill,

As far as I can judge without actually trying this code, it would not work, if you enter a space, when hit BackSpace or delete (e.g. Number of spaces will be incorrect). BTW, you made a typo in a "reset" word.

Anyway, let me be wrong and I think, you're on the right track. What about initialization this control as space(30) by default?

>Nadya,
>
>>you still have a workaround using a KeyPress method, but it would be akward... :(
>
>it got it! and it's (finally) pretty simple. I count trailing spaces in the KeyPress method, then adjust the string in the valid. Here it is, w/a bit of initialization, etc. in other places:
>
>In KeyPress:
>
>WITH THISFORM
>  IF CHR( m.nKeyCode ) = " "	&& user entered space
>    IF .lLastWasSpace
>      .nTrailingSpaces = .nTrailingSpaces + 1 && found consecutive spaces, count this one
>    ELSE
>      .nTrailingSpaces = 1 && found a space after a non-space, count and reest flag
>      .lLastWasSpace = .T.
>    ENDIF
>  ELSE	&& not a space - forget counting
>    .lLastWasSpace = .F.
>  ENDIF
>ENDWITH
>
>In Valid:
>** get characters actually typed, including trailing spaces
>.cCharsEntered = RTRIM( This.Value )
>IF .lLastWasSpace && last printable character user typed was a space
>  .cCharsEntered = .cCharsEntered + SPACE( .nTrailingSpaces ) && put spaces back
>ENDIF
>
>
>Thanks for your interest and input...it's great to have a place like this to help work through things....J
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform