You’ll have to watch for multiple EndOfLines after a paragraph, though. You might want to replace multiple endoflines with a single one before doing the countfields.
What I do not - yet - tested is if each “EndOfLine” (understand Paragraph) have one or more characters.
I indexed the TextArea contents, so asking for UBound gaves me that value, but…
This is preliminary work, I do not know yet how the Lego bricks will be set (?) Look, I cannot write (yet) what I want !
Back home, I will test the advice(s) and decide what to do.
I want to be able to get the text from the paragraph were the Cursor resides. So, an empty paragraph is tested later. But I have to implement the code to be sure.
Maybe split the text from the start to selection start over endofline and then iterate through the array trimming the lines and looking for changes between empty and non empty lines. This would catch invisible spaces on “empty” lines.