RTB.SelText="100 "
RTB.SelText="200"
Получу следующее:
100 200
А как сделать чтобы было так ?
100
200
Т.е. чтобы печаталось с новой строки ?
Private Const EM_GETSEL As Long = &HB0
Private Const EM_LINEFROMCHAR As Long = &HC9
Private Const EM_LINEINDEX As Long = &HBB
Private Const EM_LINELENGTH As Long = &HC1
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Option Explicit
Private Sub RTBedit_SelChange()
Dim lSelStart As Long, lSelLength As Long
Dim CharPos As Long, Lineindex As Long, LineLength As Long, ColIndex As Long
Dim Ret As Long, arrTmp() As String
If Not (Me.Visible) Then Exit Sub
With RTBedit
Ret = SendMessage(.hwnd, EM_GETSEL, lSelStart, lSelLength)
Lineindex = SendMessage(RTBedit.hwnd, EM_LINEFROMCHAR, lSelLength, 0) + 1
LineLength = SendMessage(.hwnd, EM_LINELENGTH, Lineindex - 1, 0)
CharPos = SendMessage(RTBedit.hwnd, EM_LINEINDEX, -1, 0)
ColIndex = lSelLength - CharPos
If .SelLength > 0 Then
arrTmp() = Split(.SelText, vbCrLf)
LblStatus.Caption = "Selected: Lines - " & IIf(UBound(arrTmp) = 0, 1, UBound(arrTmp)) & ": Symbols - " & .SelLength
Else
LblStatus.Caption = "Line " & Lineindex & ": Col " & ColIndex
End If
End With
End Sub
Private Function GetCurrentLineLen() As Long
Dim S As String
Dim nLen As Long
Dim nChar As Long
Const nLine = 2
nChar = SendMessage(RTBedit.hwnd, EM_LINEINDEX, Lineindex - 1, ByVal 0&)
If nChar <> -1 Then
nLen = SendMessage(RTBedit.hwnd, EM_LINELENGTH, nChar, ByVal 0&)
If nLen < 2 Then nLen = 2
S = String$(2, 0)
CopyMemory ByVal S, nLen, 2
S = S & String$(nLen - 2, 0)
nLen = SendMessage(RTBedit.hwnd, EM_GETLINE, Lineindex - 1, ByVal S)
GetCurrentLineLen = Len(Left$(S, nLen))
Else
GetCurrentLineLen = 0
End If
End Function
Сейчас этот форум просматривают: AhrefsBot, SemrushBot и гости: 13