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 Const EM_LINEFROMCHAR = &HC9 Const EM_LINEINDEX = &HBB
Sub TextBoxGetLineColumn(tb As TextBox, ByVal charIndex As Long, line As Long, _ column As Long) If charIndex < 0 Then charIndex = tb.SelStart line = SendMessage(tb.hwnd, EM_LINEFROMCHAR, charIndex, ByVal 0&) column = tb.SelStart - SendMessage(tb.hwnd, EM_LINEINDEX, line, ByVal 0&) End Sub |