Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Determine # of characters input in a field
Message
De
28/02/2003 10:47:05
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00759242
Message ID:
00759403
Vues:
22
Hello Allan

I needed that feature in an application I made in the good, old DOS-days, and it was really very simple then:

I started with a variable with the value of REPLICATE(CHR(178),200). In DOS CHR(178) is a block with grey background, 200 gave the value a length which was way too long. My client could only see a very small portion of the value. If my client hit backspace and/or Delete too many times they could in theory break my procedure, but it never happened. In VFP you can make it much longer to be on the safe side.

When my customers entered their input, the CHR(178)'s were replaced with their input. So I could simply use a chrtran() to remove the redudant CHR(178)'s and I knew what they had entered, including all spaces, also the leading and trailing, plus the length of their input.

I never had the same need in VFP, but it should be very easy to adapt my solution. Either you can use a font with a symbol similar to CHR(178) in DOS, like Foxfont, or you can experiment with some other CHR-value.

Good luck!

>Alan,
>
>Thanks for the suggestion.
>
>IMHO, it seems like a very basic requirement to know the length of the user input.
>I find it hard to believe that after all these years and versions of VFP that it is not available as a simple function.
>
>>I doubt there is a way to do it without somehow using the keypress event to capture individual keystrokes. It doesn't need to be very complicated though. You only really need to worry about the keypress of the spacebar. If you just count the space keys, then you can add them to the normal "Len(AllTrim(text1.text))"
>>
>>Alan
>>
>>>Is it possible (without using keypress) to determine the # of characters (including trailing blanks) in a field?
>>>For example, I have a field in an form (no control source) that has an input mask of =replicate('X',30). If 'abc' or 'abc ' is input, the length of this.value is 30. If I check the length of the alltrim, it is 3, of course.
>>>Or to present the question another way ... How would I determine * exactly * what the user entered?
>>>TIA.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform