strLength problem

SarahWard

Banned
I am using the string length keyword to find the length of a string 'ItemTitle'.

When I present the StrLength routine with this string it throws up an error message

"Input String was not in a correct format".

However, the string value seems quite valid. This value is displayed in the forms titlebar in the attached image. The value of ItemTitle is 'Amanita Ceasarea'.

I defined ItemTitle as a string in the public area with Itemtitle = "Pocket Fungi".

I cannot understand why keyword StrLength would throw out this string when it holds a valid string value. This is not the first time I have had problems using StrLength keyword.



I have been programming since the MSDOS/ASM days but I never had troubles with QuickBasic or the Visual Basic string-length keyword. Nor with Borland C.

If this keyword has problems with string values maybe we need a keyword 'Cvt2String' which would take a string or numeric variable and make a properly formatted, 'happy-bunny' string out of it?

Anyone explain it to a small-brained programmer?

Thanks guys

Sarah
 

derez

Expert
Licensed User
Longtime User
Sarah
If itemtitle is a variable , holding a string in it , you should refer to it as itemtitle, not as 'itemtitle'

The strlength works for me.

The help say:
Returns the length of a string (number of characters).
Syntax: StrLength (String)


Example: Msgbox (StrLength ("Basic4ppc"))
Result: Displays 9

So either a variable without ' or " , or a string with "xxxx" .
 

mjcoon

Well-Known Member
Licensed User
itemtitle is a variable , holding a string in it , you should refer to it as itemtitle, not as 'itemtitle'

But in Sarah's image there are no apostrophes ' in the code shown.

Perhaps it is not the StrLength() that is the problem. How about embedding it in a different context, such as
MsgBox("Length = " & StrLength(ItemTitle)) .

(I wonder if the bracketing was the problem. But I do understand the problem of the implicit variant nature of Basic4PPC variables.)

Mike.
 

SarahWard

Banned
Thanks Derez, Mjcoon is correct. I used single monstroncities around ItemTitle for descriptive reasons. ;)

Andrew...

Thanks for the suggestion. I will try it out. :)

Thanks everyone, for helping. Sometimes I can be a dummy when it comes to programming. :sign0161:

Sarah
 
Top