VB Code:
'Declaring Sendmessage API
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_GETLINECOUNT = &HBA
'Declaring oldline
Public Oldline As Integer
Private Sub Form_Load()
'Setting a default value for the RTB(Could do a _Change here instead)
txtLinecounter.Text = "1"
End Sub
Private Sub txtMain_Change()
Dim iLines As Long
Dim i As Integer
iLines = SendMessage(txtMain.hwnd, EM_GETLINECOUNT, 0, 0)
If Not iLines = Oldline Then
txtLinecounter.Text = ""
For i = 1 To iLines
txtLinecounter.Text = txtLinecounter.Text & i & vbCrLf
Next
txtLinecounter.SelStart = InStr(1, Liner, iLines - 1)
Oldline = iLines
Else
Oldline = iLines
End If
End Sub