Upravený kód Do modulu vložte deklaraci a obě upravené procedury
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const EM_LINEINDEX = &HBB
Public Const EM_GETLINECOUNT = &HBA
Public Const EM_GETLINE = &HC4
Public Const EM_LINELENGTH = &HC1
Public I As Integer, xPocet as Integer, xTabul() as String
Public Sub CtiText(ByRef TextBox As Object)
xPocet = SendMessage(TextBox.hwnd, EM_GETLINECOUNT, 0, 0)
ReDim xTabul(xPocet)
For I = 1 To SendMessage(TextBox.hwnd, EM_GETLINECOUNT, 0, 0)
SendMessage TextBox.hwnd, EM_LINEINDEX, I - 1, 0
xTabul(I) = CtiTextGetline(I - 1, TextBox.hwnd)
Next I
End Sub
Private Function CtiTextGetline(ByVal iLine As Long, ByVal lHwnd As Long) As String
Dim bLine() As Byte, lngLen As Long
lngLen = SendMessage(lHwnd, EM_LINELENGTH, SendMessage(lHwnd, _
EM_LINEINDEX, iLine, 0), 0)
ReDim bLine(lngLen + 1)
bLine(0) = lngLen And 255
bLine(1) = lngLen \ 256
SendMessage lHwnd, EM_GETLINE, iLine, bLine(0)
CtiTextGetline = Left(StrConv(bLine, vbUnicode), lngLen)
End Function
Do výkonného formuláře se jménem Form1, který např. obsahuje TextBox1 a CommandButton1
Private Sub CommandButton1_Click()
CtiText TextBox1
'naplní proměnnou xPocet - počet řádků tabulky xTabul,
'která obsahuje jednotlivé řádky TextBox1
For I = 1 To xPocet
'práce s jednotlivými xTabul(I)
Next I
|