I forgot i had this code.
In the SelChange Event add this code:Code:Option Explicit Private Declare Function SendMessageLong Lib "user32" Alias _ "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Long) As Long Private Const EM_LINEFROMCHAR = &HC9 Private Const EM_LINEINDEX = &HBB Private Const EM_LINELENGTH = &HC1 Public Sub GetEditStatus() Dim lLine As Long, lCol As Long Dim cCol As Long, lChar As Long, i As Long lChar = RichTextBox1.SelStart + 1 ' Get the line number lLine = 1 + SendMessageLong(RichTextBox1.hWnd, EM_LINEFROMCHAR, _ rtf1.SelStart, 0&) ' Get the Character Position cCol = SendMessageLong(RichTextBox1.hWnd, EM_LINELENGTH, lChar - 1, 0&) i = SendMessageLong(RichTextBox1.hWnd, EM_LINEINDEX, lLine - 1, 0&) lCol = lChar - i ' Caption of Label1 is set to Cursor Position. ' This could also be a panel in a StatusBar. Label1.Caption = lLine & ", " & lCol End Sub
Code:Private Sub RichTextBox1_SelChange() GetEditStatus End Sub




Reply With Quote