Lines in text field

Is there any way to tell number on lines in a text field?

So that the field size can be adjusted. This is for a web Read only field.

Inserted lines at runtime? Without word wrapping could be counting the lines like TextArea1.Text.CountFields(EndOfLine)
I don’t know if there is a reliable way of counting “visible lines” (wrapped).

Thanks Rick.

Did not work. With any number of lines, some via returns and some by auto line break it always showed 1.


Tested wrong field. This time it showed, 1,3,9. The one which showed 9 actually had 10 lines, one was a long line .

Not sure what I can do with this but it’s a start.

Thank again.

Yep. It counts “Internal/real lines” not “visible/virtual lines”. Three visible lines with just one real line break counts as one this way. :stuck_out_tongue:

How about graphics.stringheight / graphics.textheight?

It could work through a WebStyle where a specific standard font and point size is specified. Arial for instance is present on both Mac and Windows, so browsers will be able to use it on these two platforms.

However, browsers allow users to tweak the choice of fonts and their size, so the method is not as reliable as in a desktop app.

But as fields automatically show a scroll bar if text exceeds the size of the control, if the autosize is wrong, the content remains accessible.

That may offer me a challenge to work on after I get this WE app up and running. The last time I did something like that was in C back in Mac OS 8 or 9 or before.