Everyone has been real good to me and shared their ideas and code snippits - here's mine for a richtextbox(RTB):
Option Explicit
Private Type POINT_TYPE
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINT_TYPE) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
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 Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Const WM_VSCROLL = &H115
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINEFROMCHAR = &HC9
Private Const EM_CHARFROMPOS = &HD7
Private Const SB_LINEUP = 0
Private Const SB_LINEDOWN = 1
Dim x, y
Private Sub RTB_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Or KeyCode = vbKeyRight Then
Dim lP As POINT_TYPE
lP.x = x \ Screen.TwipsPerPixelX
lP.y = y \ Screen.TwipsPerPixelY
Dim lRow As Long, lCol As Long, aLine As String
lRow = SendMessage(RTB.hwnd, EM_LINEFROMCHAR, -1, ByVal 0)
lCol = RTB.SelStart - SendMessage(RTB.hwnd, EM_LINEINDEX, lRow, ByVal 0)
lblPos.Caption = Str(lRow) & "," & Str(lCol)
End If
End Sub
Enjoy,
Old Man
