hola como estan? resulta que yo tengo un textbox multiline con varias lineas y las lineas siempre son diferentes cantidades y dicen distintas cosas
linea 1
linea 2
linea 3
linea 4
entonces yo quiero obtener la linea que dice linea 3 y pasarla a otro textbox alguien sabria? gracias
Usas la función
splitCitarPrivate Sub Command1_Click()
Dim sArray() As String
sArray = Split(Text1.Text, vbCrLf)
MsgBox sArray(2)
End Sub
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Private Const EM_GETLINE As Long = &HC4
Private Const EM_LINELENGTH As Long = &HC1
Function GetLineText(TextBox As TextBox, Optional LineNumer As Long = 1) As String
Dim lc As Long, Ret As Long, Str As String
lc = SendMessage(TextBox.hwnd, EM_GETLINECOUNT, 0&, 0&)
Ret = SendMessage(TextBox.hwnd, EM_LINELENGTH, (LineNumer - 1), 0&)
Str = Space(Ret)
SendMessage TextBox.hwnd, EM_GETLINE, (LineNumer - 1), Str
GetLineText = Str
End Function
Private Sub Command1_Click()
MsgBox GetLineText(Text1, 3)
End Sub