AFAIK, there’s no “LineCount” method for TextArea, and instead we need to use .LineNumber(lengthOfText) + 1 to get the line count. Except the method returns incorrect results if the last line is has less than two characters.
I don’t think the function has ever worked correctly since the transition to Cocoa. I logged a similar issue #51461 several years ago which was found when we moved from RB to Xojo.
If you have the MBS plugins the following might solve the problem for macOS.
Dim textViewObj As NSTextViewMBS
Dim layoutManagerObj As NSLayoutManagerMBS
Dim glyphCount As Int32
Dim index As Int32
Dim rowCount As Int32
Dim lineRangeObj As NSRangeMBS
textViewObj = TextArea1.NSTextViewMBS
layoutManagerObj = textViewObj.layoutManager
glyphCount = layoutManagerObj.glyphRangeForTextContainer(textViewObj.textContainer).MaxRange
index = 0
rowCount = 0
While (rowCount < glyphCount) And (index < glyphCount)
Call layoutManagerObj.lineFragmentRectForGlyphAtIndex(index, lineRangeObj)
index = lineRangeObj.MaxRange
rowCount = rowCount + 1