如何从多行文本框到单个文本框?

时间:2016-12-18 22:10:38

标签: vb.net vb.net-2010

THAT'S PREVIEW APP

如何获取最后一行例如:DD D5 08 0C 0C 20 08 00 90 00从多行文本框到单个文本框,

我希望当我点击按钮1我得到最后一个结果(DD D5 08 0C 0C 20 08 00 90 00)到单个文本框

请帮助我亲爱的

我的代码如下:

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 个答案:

答案 0 :(得分:0)

使用MultiLine TextBox的Lines()属性...

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

如果TextBox末尾可能有不确定数量的空白行,则向后走LINE()数组 ,直到找到第一个非空白行:

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