How To Get Line From Multiline Textbox to single textbox?

2.5k Views Asked by At

THAT'S PREVIEW APP

how to get the last line eg: DD D5 08 0C 0C 20 08 00 90 00 from multiline text box to single textbox,

i want when i click button 1 i get just last result (DD D5 08 0C 0C 20 08 00 90 00) to single textbox

pleaze help me dear

my code is look like :

Public Sub displayOut(ByVal errorType As Integer, ByVal returnValue As Integer, ByVal printText As String)

    TextBoxLogs.Text += printText & vbCrLf
    TextBoxLogs.SelectionStart = TextBoxLogs.Text.Length
    TextBoxLogs.ScrollToCaret()
    TextBoxLogs.Refresh()

End Sub

Private Sub ButtonGetCardInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetCardInfo.Click

    displayOut(1, 0, "Card unique serial number")
    'CardCommands.getCardUniqueSerialNumber()

    If Not Common.isSuccessful Then
        Return
    End If

  End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Common.clearBuffers()

    Common.sendBuff(0) = &H80   'CLA
    Common.sendBuff(1) = &H14   'INS
    Common.sendBuff(2) = &H0    'P1
    Common.sendBuff(3) = &H0    'P2
    Common.sendBuff(4) = &H8    'LE

    Common.sendLen = 5
    Common.recvLen = 255

    Common.returnCode = Common.sendApdu(2)

    ErrorCodes.interpretReturnStatus()

End Sub
1

There are 1 best solutions below

3
On BEST ANSWER

Use the Lines() property of the MultiLine TextBox...

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    SingleTextBox.Text = TextBoxLogs.Lines(TextBoxLogs.Lines.GetUpperBound(0))
End Sub

If you may have an indeterminate number of blank lines at the end of the TextBox, then walk the Lines() array backwards until you find the first non-blank one:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    For i As Integer = TextBoxLogs.Lines.GetUpperBound(0) To 0 Step -1
        If TextBoxLogs.Lines(i).Trim <> "" Then
            SingleTextBox.Text = TextBoxLogs.Lines(i)
            Exit For
        End If
    Next
End Sub