how to use Declare function for get count num of line in TextArea

LineNumAtCharPos starts counting at 0, so in both solutions you have to add 1 to the result.

test:
put a textarea and a button on a window then the following code in the button’s action event:

[code] For i As Integer = 1 To 10
TextArea1.AppendText Str(i)
If i <10 Then TextArea1.AppendText EndOfLine
Next i

MsgBox Str(TextArea1.LineNumAtCharPos(TextArea1.Text.Len))

TextArea1.AppendText EndOfLine
MsgBox Str(TextArea1.LineNumAtCharPos(TextArea1.Text.Len))
[/code]

a line of text doesn’t have to end with a EndOfLine, that’s why i splitted adding the text (str(i)) and adding the EndOfLine in two steps.
This way you can see that adding the EndOfLine doesn’t increase the number of lines.