I have been asked today how to check, if the cursor is in the last line.

Here is the resulting code snippet, which includes the extra check for the last text position in the document:

Private Function IsLastLine() As Boolean
    If TXTextControl1.SelStart = Len(TXTextControl1.Text) Or TXTextControl1.GetLineFromChar(TXTextControl1.SelStart) + 1 = TXTextControl1.GetLineCount Then
        IsLastLine = True
        IsLastLine = False
    End If
End function

If you have any suggestions or comments please feel free to drop us a line.