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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What len(thisform.text1.value) will return? 3

Status
Not open for further replies.

greathope123

Programmer
Nov 1, 2011
84
GB
Hi,

In VFP, I found
?len(thisform.text1.value)
returned something related to the length of the text1 box, not the length of the string in the box.

Anything I was missing??
 
Aha, I see where the Tek-Tips Submit Post removed the 'extra spaces' from my post so that my example does not appear as intended.

Code:
For example:
MyTable.UserID = "12345 " && Note number of trailing spaces
cFindThis = "12345 " && Note different number of trailing spaces

The value for MyTable.UserID was entered with 4 trailing spaces whereas the value for cFindThis was entered with only 2 trailing spaces.
But when I did the Submit Post, those 'extra' trailing spaces were removed and therefore my example comes across as - WHAT ????

Sorry for the confusion, but you get the idea I hope.

Good Luck,
JRB-Bldr


 
use table1
locate for alltrim(username)=alltrim(thisform.text1.value)
if found()
......

but, why? A VFP bug?

Behavior by design, and it trips up a lot of people until they know about it.

The way VFP handles string comparison is character-by-character, but it stops once one side runs out of characters and reports the result so far:

Code:
? "xx" = "x" && .t.
? "x" = "xx" && .f.

The double equal (or "exactly equal") operator can force full comparison, but it has performance implications.

It's just how the tool works. Knowing this, you can write safer code.
 
Thank you so much, I got a lot things I did not know....

I have just tried:
for i=1 to len(thisform.text1.text)
?asc(substr(thisform.text1.text,i))
endfor
and got a lot of "32" - the spaces at the end of the text in text1.
 
Thank you again.
Just want to say sorry: I clicked a red flag by mistake!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top