A few simple textbox functions
VB Code:
Option Explicit 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 Private Const EM_LINEFROMCHAR = &HC9 Private Const EM_LINELENGTH = &HC1 Private Function GetLineCount(txt As TextBox) As Long GetLineCount = SendMessage(txt.hwnd, EM_GETLINECOUNT, ByVal 0&, ByVal 0&) End Function Private Function GetCurrentLine(txt As TextBox) As Long GetCurrentLine = SendMessage(txt.hwnd, EM_LINEFROMCHAR, ByVal txt.SelStart, ByVal 0&) + 1 End Function Private Function GetLineLength(txt As TextBox, line As Long) As Long GetLineLength = SendMessage(txt.hwnd, EM_LINELENGTH, ByVal line, ByVal 0&) End Function Private Sub Command1_Click() MsgBox GetLineCount(Text1) MsgBox GetCurrentLine(Text1) MsgBox GetLineLength(Text1, GetCurrentLine(Text1)) End Sub




Reply With Quote