height of text in textArea


I need to size a textarea to display the all text of it without any scrollbar and for a specific Width.

is there a way to return the height of the text in a textarea no matter what the fontzise and other parameters of the object.


Your question is unclear for me. Can you elaborate a bit ?

A character always have a text height.

Just tested, on Mac that works…

textarea1.ScrollPosition = 999999999 if TextArea1.ScrollPosition > 0 then 'make it higher end if

I don’t understand, that just scroll the text to the end and TextArea1.ScrollPosition always > 0 in this case !

I need to calculate the height of all text in the textArea to display the all text, to size the textArea Height exactly to the height of the all text (all the text lines).

It is not, it is “Use to get or set the topmost visible line (zero-based).”
Did you tried it?

Yes, i try it and it scroll the text to the bottom because the value is more than the number of line.
But then i dont understand what you whant to test. Because TextArea1.ScrollPosition is always > 0.

I have a textArea with a text much longer than the textArea height and i need to determine the perfect hight to display all the text.

It’s work testing the TextArea1.CharPosAtXY(0,0).
When you scroll to the end and the TextArea1.CharPosAtXY(0,0) = 0 then all the text is displayed !

Here it is !

textarea1.ScrollPosition = 999999999 Do until TextArea1.CharPosAtXY(0,0) = 1 textarea1.Height = textarea1.Height + 10 loop

Put short text in it, that fits into the Textarea and you will see it is 0

You’re right ! I havent’ testing it right.
Thanks a lot !

How tall is your monitor ?

Th trick I would use is to create a Picture,

set g.TextFont to the Listbox TextFont,
set g.TextSize to the Listbox TextSize,
set g.StringWidth to the Listbox Width

use g.StringHeight to get the whole height needed to draw all the text.

At last, I use the height value to set the Window / TextArea height. (thus the question above).

Read there:

Naturally, I may not understand your question.

Thanks Emile it’s exactly what i search.

Naturally, I may not understand your question.
I just needed to determine the height of a text in a textArea to display the textArea at the exact height of the text.