Due to some weird circumstance, I am now having to manipulate the arrow key navigation on an active textbox. I figured I can use the API to get information on the lines... Here is my unfinished code snippet

Code:
Dim startSel As Long, endSel As Long
    Dim delta As Long, lineCnt As Long, currentLine As Long
    
    'Get the initial values
    SendMessageLong activeTextBox.hwnd, EM_GETSEL, startSel, endSel
    delta = endSel
    'lines are 0-based
    lineCnt = SendMessageLong(activeTextBox.hwnd, EM_GETLINECOUNT, 0, 0)
    currentLine = SendMessageLong(activeTextBox.hwnd, EM_LINEFROMCHAR, delta, 0)
    'calculate delta
    Select Case KeyCode
        Case vbKeyUp
            'calculate up
            If currentLine > 0 Then
                
            End If
        Case vbKeyDown
            'calculate down
            If currentLine < lineCnt - 1 Then
                
            End If
        Case vbKeyLeft
            'calculate left
            If delta > 0 Then
                delta = delta - 1
            End If
        Case vbKeyRight
            'calculate right
            delta = delta + 1
    End Select
Now for the KeyUp and Keydown, I need to place the current cursor into the correct line. Currently, what I have in mind is to calculate the character index for each line and get the delta character change and use that to send an api call for EM_SETSEL.

Basically what I'd do is, call sendmessage on EM_GETLINE, get all character count, determine the line where delta should fall, determine the new char index from that line and then add the character counts of all preceding lines, and that will be my delta.

Is there another straightforward API call for this? or some other clever way perhaps?