Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Length of a string in a text box

Status
Not open for further replies.

Toman

Technical User
Mar 30, 2004
190
CZ
Hi,
Sorry for such a basic question.

In textbox one writes a character expression that I later search in a table.
Because text property returns some additional spaces I use
Code:
ALLTRIM(thisform.txtFind.text)
as a search string.
It looked good till now, when someone want to distinguish between "Smith Wesson" and "SmithWesson". He writes "Smith " (space after the letter h) into the box, willing not to get SmithWesson records as an answer, but he gets back both types of records, because the space in his question is discarded by ALLTRIM function.
To solve this I can imagine only creating my own text property by collecting characters as they are typed (KeyPress method, watch out backspace, etc.). I hope that professionals are dealing with this other way.

Thank you for any tip, Tom.
 
No doubt that comes from the idea that you can discard things by throwing them into a ditch.

To be more exact, I think it comes from RAF slang. "The ditch" meant the sea -- in particular, the sea around the British Isles (possibly from the idea of a protective ditch or motte around a castle). The verb "to ditch" then came to mean to deliberatly crash your aircraft into the sea. From there, it's not much further to the current meaning, "to get rid of, or discard, something".

At least, that's what I assume. Chambers doesn't give an etymology.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Friends, how can I get rid of the maxlength, a Textbox property . Should I throw out the Textbox into a ditch?

Tom
 
Sorry, for confusing you so much with slang language. Yes, I simply meant to keep the maxlength at 0, where it is by default. Don't use it.

I also said: If someone enters longer text you can trim it to a max length when searching.

So if you dont limit the length by maxlength, you can still use LEFT(), when LEN(txtSearch.value)>maxlength.

But if you fear users search for longer terms than can be stored in the table field, I'd not worry about that. This will simply not find any result.

Bye, Olaf.
 
If I set MaxLength to 0, still some maximal length exists. (textboxes in HTML forms behaves differently)
See VFP helpfile:
The number of characters that can be entered into a text box when nMaxLength is set to 0 is determined by the size of the textbox and its data type.
In this situation I am not able to retrieve entered text with leading/ trailing spaces according to Olaf's recommendation. Either I can get "full textbox" length string with lot of spaces, or use some TRIM command and lost leading/ trailing spaces.
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top